|
@@ -1164,9 +1164,13 @@ ip_vs_add_service(struct net *net, struct ip_vs_service_user_kern *u,
|
|
|
}
|
|
|
|
|
|
#ifdef CONFIG_IP_VS_IPV6
|
|
|
- if (u->af == AF_INET6 && (u->netmask < 1 || u->netmask > 128)) {
|
|
|
- ret = -EINVAL;
|
|
|
- goto out_err;
|
|
|
+ if (u->af == AF_INET6) {
|
|
|
+ __u32 plen = (__force __u32) u->netmask;
|
|
|
+
|
|
|
+ if (plen < 1 || plen > 128) {
|
|
|
+ ret = -EINVAL;
|
|
|
+ goto out_err;
|
|
|
+ }
|
|
|
}
|
|
|
#endif
|
|
|
|
|
@@ -1277,9 +1281,13 @@ ip_vs_edit_service(struct ip_vs_service *svc, struct ip_vs_service_user_kern *u)
|
|
|
}
|
|
|
|
|
|
#ifdef CONFIG_IP_VS_IPV6
|
|
|
- if (u->af == AF_INET6 && (u->netmask < 1 || u->netmask > 128)) {
|
|
|
- ret = -EINVAL;
|
|
|
- goto out;
|
|
|
+ if (u->af == AF_INET6) {
|
|
|
+ __u32 plen = (__force __u32) u->netmask;
|
|
|
+
|
|
|
+ if (plen < 1 || plen > 128) {
|
|
|
+ ret = -EINVAL;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
}
|
|
|
#endif
|
|
|
|
|
@@ -1460,8 +1468,11 @@ void ip_vs_service_net_cleanup(struct net *net)
|
|
|
static inline void
|
|
|
ip_vs_forget_dev(struct ip_vs_dest *dest, struct net_device *dev)
|
|
|
{
|
|
|
+ struct ip_vs_dest_dst *dest_dst;
|
|
|
+
|
|
|
spin_lock_bh(&dest->dst_lock);
|
|
|
- if (dest->dest_dst && dest->dest_dst->dst_cache->dev == dev) {
|
|
|
+ dest_dst = rcu_dereference_protected(dest->dest_dst, 1);
|
|
|
+ if (dest_dst && dest_dst->dst_cache->dev == dev) {
|
|
|
IP_VS_DBG_BUF(3, "Reset dev:%s dest %s:%u ,dest->refcnt=%d\n",
|
|
|
dev->name,
|
|
|
IP_VS_DBG_ADDR(dest->af, &dest->addr),
|
|
@@ -1934,8 +1945,8 @@ static struct ip_vs_service *ip_vs_info_array(struct seq_file *seq, loff_t pos)
|
|
|
}
|
|
|
|
|
|
static void *ip_vs_info_seq_start(struct seq_file *seq, loff_t *pos)
|
|
|
+ __acquires(RCU)
|
|
|
{
|
|
|
-
|
|
|
rcu_read_lock();
|
|
|
return *pos ? ip_vs_info_array(seq, *pos - 1) : SEQ_START_TOKEN;
|
|
|
}
|
|
@@ -1990,6 +2001,7 @@ static void *ip_vs_info_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
|
|
}
|
|
|
|
|
|
static void ip_vs_info_seq_stop(struct seq_file *seq, void *v)
|
|
|
+ __releases(RCU)
|
|
|
{
|
|
|
rcu_read_unlock();
|
|
|
}
|
|
@@ -2134,7 +2146,7 @@ static int ip_vs_stats_percpu_show(struct seq_file *seq, void *v)
|
|
|
{
|
|
|
struct net *net = seq_file_single_net(seq);
|
|
|
struct ip_vs_stats *tot_stats = &net_ipvs(net)->tot_stats;
|
|
|
- struct ip_vs_cpu_stats *cpustats = tot_stats->cpustats;
|
|
|
+ struct ip_vs_cpu_stats __percpu *cpustats = tot_stats->cpustats;
|
|
|
struct ip_vs_stats_user rates;
|
|
|
int i;
|
|
|
|
|
@@ -2871,6 +2883,7 @@ static int ip_vs_genl_fill_service(struct sk_buff *skb,
|
|
|
struct ip_vs_service *svc)
|
|
|
{
|
|
|
struct ip_vs_scheduler *sched;
|
|
|
+ struct ip_vs_pe *pe;
|
|
|
struct nlattr *nl_service;
|
|
|
struct ip_vs_flags flags = { .flags = svc->flags,
|
|
|
.mask = ~0 };
|
|
@@ -2887,17 +2900,17 @@ static int ip_vs_genl_fill_service(struct sk_buff *skb,
|
|
|
} else {
|
|
|
if (nla_put_u16(skb, IPVS_SVC_ATTR_PROTOCOL, svc->protocol) ||
|
|
|
nla_put(skb, IPVS_SVC_ATTR_ADDR, sizeof(svc->addr), &svc->addr) ||
|
|
|
- nla_put_u16(skb, IPVS_SVC_ATTR_PORT, svc->port))
|
|
|
+ nla_put_be16(skb, IPVS_SVC_ATTR_PORT, svc->port))
|
|
|
goto nla_put_failure;
|
|
|
}
|
|
|
|
|
|
sched = rcu_dereference_protected(svc->scheduler, 1);
|
|
|
+ pe = rcu_dereference_protected(svc->pe, 1);
|
|
|
if (nla_put_string(skb, IPVS_SVC_ATTR_SCHED_NAME, sched->name) ||
|
|
|
- (svc->pe &&
|
|
|
- nla_put_string(skb, IPVS_SVC_ATTR_PE_NAME, svc->pe->name)) ||
|
|
|
+ (pe && nla_put_string(skb, IPVS_SVC_ATTR_PE_NAME, pe->name)) ||
|
|
|
nla_put(skb, IPVS_SVC_ATTR_FLAGS, sizeof(flags), &flags) ||
|
|
|
nla_put_u32(skb, IPVS_SVC_ATTR_TIMEOUT, svc->timeout / HZ) ||
|
|
|
- nla_put_u32(skb, IPVS_SVC_ATTR_NETMASK, svc->netmask))
|
|
|
+ nla_put_be32(skb, IPVS_SVC_ATTR_NETMASK, svc->netmask))
|
|
|
goto nla_put_failure;
|
|
|
if (ip_vs_genl_fill_stats(skb, IPVS_SVC_ATTR_STATS, &svc->stats))
|
|
|
goto nla_put_failure;
|
|
@@ -3010,7 +3023,7 @@ static int ip_vs_genl_parse_service(struct net *net,
|
|
|
} else {
|
|
|
usvc->protocol = nla_get_u16(nla_protocol);
|
|
|
nla_memcpy(&usvc->addr, nla_addr, sizeof(usvc->addr));
|
|
|
- usvc->port = nla_get_u16(nla_port);
|
|
|
+ usvc->port = nla_get_be16(nla_port);
|
|
|
usvc->fwmark = 0;
|
|
|
}
|
|
|
|
|
@@ -3050,7 +3063,7 @@ static int ip_vs_genl_parse_service(struct net *net,
|
|
|
usvc->sched_name = nla_data(nla_sched);
|
|
|
usvc->pe_name = nla_pe ? nla_data(nla_pe) : NULL;
|
|
|
usvc->timeout = nla_get_u32(nla_timeout);
|
|
|
- usvc->netmask = nla_get_u32(nla_netmask);
|
|
|
+ usvc->netmask = nla_get_be32(nla_netmask);
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
@@ -3076,7 +3089,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
|
|
|
return -EMSGSIZE;
|
|
|
|
|
|
if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
|
|
|
- nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
|
|
|
+ nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
|
|
|
nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
|
|
|
(atomic_read(&dest->conn_flags) &
|
|
|
IP_VS_CONN_F_FWD_MASK)) ||
|
|
@@ -3185,7 +3198,7 @@ static int ip_vs_genl_parse_dest(struct ip_vs_dest_user_kern *udest,
|
|
|
memset(udest, 0, sizeof(*udest));
|
|
|
|
|
|
nla_memcpy(&udest->addr, nla_addr, sizeof(udest->addr));
|
|
|
- udest->port = nla_get_u16(nla_port);
|
|
|
+ udest->port = nla_get_be16(nla_port);
|
|
|
|
|
|
/* If a full entry was requested, check for the additional fields */
|
|
|
if (full_entry) {
|
|
@@ -3210,8 +3223,8 @@ static int ip_vs_genl_parse_dest(struct ip_vs_dest_user_kern *udest,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int ip_vs_genl_fill_daemon(struct sk_buff *skb, __be32 state,
|
|
|
- const char *mcast_ifn, __be32 syncid)
|
|
|
+static int ip_vs_genl_fill_daemon(struct sk_buff *skb, __u32 state,
|
|
|
+ const char *mcast_ifn, __u32 syncid)
|
|
|
{
|
|
|
struct nlattr *nl_daemon;
|
|
|
|
|
@@ -3232,8 +3245,8 @@ nla_put_failure:
|
|
|
return -EMSGSIZE;
|
|
|
}
|
|
|
|
|
|
-static int ip_vs_genl_dump_daemon(struct sk_buff *skb, __be32 state,
|
|
|
- const char *mcast_ifn, __be32 syncid,
|
|
|
+static int ip_vs_genl_dump_daemon(struct sk_buff *skb, __u32 state,
|
|
|
+ const char *mcast_ifn, __u32 syncid,
|
|
|
struct netlink_callback *cb)
|
|
|
{
|
|
|
void *hdr;
|