@@ -1164,9 +1164,13 @@ ip_vs_add_service(struct net *net, struct ip_vs_service_user_kern *u,
11641164}
11651165
11661166#ifdef  CONFIG_IP_VS_IPV6 
1167- if  (u -> af  ==  AF_INET6  &&  (u -> netmask  <  1  ||  u -> netmask  >  128 )) {
1168- ret  =  - EINVAL ;
1169- goto out_err ;
1167+ if  (u -> af  ==  AF_INET6 ) {
1168+ __u32  plen  =  (__force  __u32 ) u -> netmask ;
1169+ 
1170+ if  (plen  <  1  ||  plen  >  128 ) {
1171+ ret  =  - EINVAL ;
1172+ goto out_err ;
1173+ }
11701174}
11711175#endif 
11721176
@@ -1277,9 +1281,13 @@ ip_vs_edit_service(struct ip_vs_service *svc, struct ip_vs_service_user_kern *u)
12771281}
12781282
12791283#ifdef  CONFIG_IP_VS_IPV6 
1280- if  (u -> af  ==  AF_INET6  &&  (u -> netmask  <  1  ||  u -> netmask  >  128 )) {
1281- ret  =  - EINVAL ;
1282- goto out ;
1284+ if  (u -> af  ==  AF_INET6 ) {
1285+ __u32  plen  =  (__force  __u32 ) u -> netmask ;
1286+ 
1287+ if  (plen  <  1  ||  plen  >  128 ) {
1288+ ret  =  - EINVAL ;
1289+ goto out ;
1290+ }
12831291}
12841292#endif 
12851293
@@ -1460,8 +1468,11 @@ void ip_vs_service_net_cleanup(struct net *net)
14601468static  inline  void 
14611469ip_vs_forget_dev (struct  ip_vs_dest  * dest , struct  net_device  * dev )
14621470{
1471+ struct  ip_vs_dest_dst  * dest_dst ;
1472+ 
14631473spin_lock_bh (& dest -> dst_lock );
1464- if  (dest -> dest_dst  &&  dest -> dest_dst -> dst_cache -> dev  ==  dev ) {
1474+ dest_dst  =  rcu_dereference_protected (dest -> dest_dst , 1 );
1475+ if  (dest_dst  &&  dest_dst -> dst_cache -> dev  ==  dev ) {
14651476IP_VS_DBG_BUF (3 , "Reset dev:%s dest %s:%u ,dest->refcnt=%d\n" ,
14661477 dev -> name ,
14671478 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)
19341945}
19351946
19361947static  void  * ip_vs_info_seq_start (struct  seq_file  * seq , loff_t  * pos )
1948+ __acquires (RCU )
19371949{
1938- 
19391950rcu_read_lock ();
19401951return  * pos  ? ip_vs_info_array (seq , * pos  -  1 ) : SEQ_START_TOKEN ;
19411952}
@@ -1990,6 +2001,7 @@ static void *ip_vs_info_seq_next(struct seq_file *seq, void *v, loff_t *pos)
19902001}
19912002
19922003static  void  ip_vs_info_seq_stop (struct  seq_file  * seq , void  * v )
2004+ __releases (RCU )
19932005{
19942006rcu_read_unlock ();
19952007}
@@ -2134,7 +2146,7 @@ static int ip_vs_stats_percpu_show(struct seq_file *seq, void *v)
21342146{
21352147struct  net  * net  =  seq_file_single_net (seq );
21362148struct  ip_vs_stats  * tot_stats  =  & net_ipvs (net )-> tot_stats ;
2137- struct  ip_vs_cpu_stats  * cpustats  =  tot_stats -> cpustats ;
2149+ struct  ip_vs_cpu_stats  __percpu   * cpustats  =  tot_stats -> cpustats ;
21382150struct  ip_vs_stats_user  rates ;
21392151int  i ;
21402152
@@ -2871,6 +2883,7 @@ static int ip_vs_genl_fill_service(struct sk_buff *skb,
28712883 struct  ip_vs_service  * svc )
28722884{
28732885struct  ip_vs_scheduler  * sched ;
2886+ struct  ip_vs_pe  * pe ;
28742887struct  nlattr  * nl_service ;
28752888struct  ip_vs_flags  flags  =  { .flags  =  svc -> flags ,
28762889 .mask  =  ~0  };
@@ -2887,17 +2900,17 @@ static int ip_vs_genl_fill_service(struct sk_buff *skb,
28872900} else  {
28882901if  (nla_put_u16 (skb , IPVS_SVC_ATTR_PROTOCOL , svc -> protocol ) || 
28892902 nla_put (skb , IPVS_SVC_ATTR_ADDR , sizeof (svc -> addr ), & svc -> addr ) || 
2890-  nla_put_u16 (skb , IPVS_SVC_ATTR_PORT , svc -> port ))
2903+  nla_put_be16 (skb , IPVS_SVC_ATTR_PORT , svc -> port ))
28912904goto nla_put_failure ;
28922905}
28932906
28942907sched  =  rcu_dereference_protected (svc -> scheduler , 1 );
2908+ pe  =  rcu_dereference_protected (svc -> pe , 1 );
28952909if  (nla_put_string (skb , IPVS_SVC_ATTR_SCHED_NAME , sched -> name ) || 
2896-  (svc -> pe  && 
2897-  nla_put_string (skb , IPVS_SVC_ATTR_PE_NAME , svc -> pe -> name )) || 
2910+  (pe  &&  nla_put_string (skb , IPVS_SVC_ATTR_PE_NAME , pe -> name )) || 
28982911 nla_put (skb , IPVS_SVC_ATTR_FLAGS , sizeof (flags ), & flags ) || 
28992912 nla_put_u32 (skb , IPVS_SVC_ATTR_TIMEOUT , svc -> timeout  / HZ ) || 
2900-  nla_put_u32 (skb , IPVS_SVC_ATTR_NETMASK , svc -> netmask ))
2913+  nla_put_be32 (skb , IPVS_SVC_ATTR_NETMASK , svc -> netmask ))
29012914goto nla_put_failure ;
29022915if  (ip_vs_genl_fill_stats (skb , IPVS_SVC_ATTR_STATS , & svc -> stats ))
29032916goto nla_put_failure ;
@@ -3010,7 +3023,7 @@ static int ip_vs_genl_parse_service(struct net *net,
30103023} else  {
30113024usvc -> protocol  =  nla_get_u16 (nla_protocol );
30123025nla_memcpy (& usvc -> addr , nla_addr , sizeof (usvc -> addr ));
3013- usvc -> port  =  nla_get_u16 (nla_port );
3026+ usvc -> port  =  nla_get_be16 (nla_port );
30143027usvc -> fwmark  =  0 ;
30153028}
30163029
@@ -3050,7 +3063,7 @@ static int ip_vs_genl_parse_service(struct net *net,
30503063usvc -> sched_name  =  nla_data (nla_sched );
30513064usvc -> pe_name  =  nla_pe  ? nla_data (nla_pe ) : NULL ;
30523065usvc -> timeout  =  nla_get_u32 (nla_timeout );
3053- usvc -> netmask  =  nla_get_u32 (nla_netmask );
3066+ usvc -> netmask  =  nla_get_be32 (nla_netmask );
30543067}
30553068
30563069return  0 ;
@@ -3076,7 +3089,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
30763089return  - EMSGSIZE ;
30773090
30783091if  (nla_put (skb , IPVS_DEST_ATTR_ADDR , sizeof (dest -> addr ), & dest -> addr ) || 
3079-  nla_put_u16 (skb , IPVS_DEST_ATTR_PORT , dest -> port ) || 
3092+  nla_put_be16 (skb , IPVS_DEST_ATTR_PORT , dest -> port ) || 
30803093 nla_put_u32 (skb , IPVS_DEST_ATTR_FWD_METHOD ,
30813094(atomic_read (& dest -> conn_flags ) & 
30823095 IP_VS_CONN_F_FWD_MASK )) || 
@@ -3185,7 +3198,7 @@ static int ip_vs_genl_parse_dest(struct ip_vs_dest_user_kern *udest,
31853198memset (udest , 0 , sizeof (* udest ));
31863199
31873200nla_memcpy (& udest -> addr , nla_addr , sizeof (udest -> addr ));
3188- udest -> port  =  nla_get_u16 (nla_port );
3201+ udest -> port  =  nla_get_be16 (nla_port );
31893202
31903203/* If a full entry was requested, check for the additional fields */ 
31913204if  (full_entry ) {
@@ -3210,8 +3223,8 @@ static int ip_vs_genl_parse_dest(struct ip_vs_dest_user_kern *udest,
32103223return  0 ;
32113224}
32123225
3213- static  int  ip_vs_genl_fill_daemon (struct  sk_buff  * skb , __be32  state ,
3214-  const  char  * mcast_ifn , __be32  syncid )
3226+ static  int  ip_vs_genl_fill_daemon (struct  sk_buff  * skb , __u32  state ,
3227+  const  char  * mcast_ifn , __u32  syncid )
32153228{
32163229struct  nlattr  * nl_daemon ;
32173230
@@ -3232,8 +3245,8 @@ static int ip_vs_genl_fill_daemon(struct sk_buff *skb, __be32 state,
32323245return  - EMSGSIZE ;
32333246}
32343247
3235- static  int  ip_vs_genl_dump_daemon (struct  sk_buff  * skb , __be32  state ,
3236-  const  char  * mcast_ifn , __be32  syncid ,
3248+ static  int  ip_vs_genl_dump_daemon (struct  sk_buff  * skb , __u32  state ,
3249+  const  char  * mcast_ifn , __u32  syncid ,
32373250 struct  netlink_callback  * cb )
32383251{
32393252void  * hdr ;
0 commit comments