diff options
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/af_inet.c | 2 | ||||
-rw-r--r-- | net/ipv4/arp.c | 12 | ||||
-rw-r--r-- | net/ipv4/fib_frontend.c | 18 | ||||
-rw-r--r-- | net/ipv4/fib_semantics.c | 4 | ||||
-rw-r--r-- | net/ipv4/icmp.c | 4 | ||||
-rw-r--r-- | net/ipv4/ip_options.c | 4 | ||||
-rw-r--r-- | net/ipv4/ipvs/ip_vs_core.c | 2 | ||||
-rw-r--r-- | net/ipv4/ipvs/ip_vs_ctl.c | 4 | ||||
-rw-r--r-- | net/ipv4/netfilter.c | 2 | ||||
-rw-r--r-- | net/ipv4/netfilter/ipt_addrtype.c | 2 | ||||
-rw-r--r-- | net/ipv4/raw.c | 2 | ||||
-rw-r--r-- | net/ipv4/route.c | 2 |
12 files changed, 30 insertions, 28 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 40ecaae7be3..d76f8d8d5eb 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -446,7 +446,7 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
446 | if (addr_len < sizeof(struct sockaddr_in)) | 446 | if (addr_len < sizeof(struct sockaddr_in)) |
447 | goto out; | 447 | goto out; |
448 | 448 | ||
449 | chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr); | 449 | chk_addr_ret = inet_addr_type(&init_net, addr->sin_addr.s_addr); |
450 | 450 | ||
451 | /* Not specified by any standard per-se, however it breaks too | 451 | /* Not specified by any standard per-se, however it breaks too |
452 | * many applications when removed. It is unfortunate since | 452 | * many applications when removed. It is unfortunate since |
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 46edf1c32a4..3f0730ec0a2 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -235,7 +235,7 @@ static int arp_constructor(struct neighbour *neigh) | |||
235 | struct in_device *in_dev; | 235 | struct in_device *in_dev; |
236 | struct neigh_parms *parms; | 236 | struct neigh_parms *parms; |
237 | 237 | ||
238 | neigh->type = inet_addr_type(addr); | 238 | neigh->type = inet_addr_type(&init_net, addr); |
239 | 239 | ||
240 | rcu_read_lock(); | 240 | rcu_read_lock(); |
241 | in_dev = __in_dev_get_rcu(dev); | 241 | in_dev = __in_dev_get_rcu(dev); |
@@ -341,14 +341,14 @@ static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb) | |||
341 | switch (IN_DEV_ARP_ANNOUNCE(in_dev)) { | 341 | switch (IN_DEV_ARP_ANNOUNCE(in_dev)) { |
342 | default: | 342 | default: |
343 | case 0: /* By default announce any local IP */ | 343 | case 0: /* By default announce any local IP */ |
344 | if (skb && inet_addr_type(ip_hdr(skb)->saddr) == RTN_LOCAL) | 344 | if (skb && inet_addr_type(&init_net, ip_hdr(skb)->saddr) == RTN_LOCAL) |
345 | saddr = ip_hdr(skb)->saddr; | 345 | saddr = ip_hdr(skb)->saddr; |
346 | break; | 346 | break; |
347 | case 1: /* Restrict announcements of saddr in same subnet */ | 347 | case 1: /* Restrict announcements of saddr in same subnet */ |
348 | if (!skb) | 348 | if (!skb) |
349 | break; | 349 | break; |
350 | saddr = ip_hdr(skb)->saddr; | 350 | saddr = ip_hdr(skb)->saddr; |
351 | if (inet_addr_type(saddr) == RTN_LOCAL) { | 351 | if (inet_addr_type(&init_net, saddr) == RTN_LOCAL) { |
352 | /* saddr should be known to target */ | 352 | /* saddr should be known to target */ |
353 | if (inet_addr_onlink(in_dev, target, saddr)) | 353 | if (inet_addr_onlink(in_dev, target, saddr)) |
354 | break; | 354 | break; |
@@ -479,7 +479,7 @@ int arp_find(unsigned char *haddr, struct sk_buff *skb) | |||
479 | 479 | ||
480 | paddr = ((struct rtable*)skb->dst)->rt_gateway; | 480 | paddr = ((struct rtable*)skb->dst)->rt_gateway; |
481 | 481 | ||
482 | if (arp_set_predefined(inet_addr_type(paddr), haddr, paddr, dev)) | 482 | if (arp_set_predefined(inet_addr_type(&init_net, paddr), haddr, paddr, dev)) |
483 | return 0; | 483 | return 0; |
484 | 484 | ||
485 | n = __neigh_lookup(&arp_tbl, &paddr, dev, 1); | 485 | n = __neigh_lookup(&arp_tbl, &paddr, dev, 1); |
@@ -806,7 +806,7 @@ static int arp_process(struct sk_buff *skb) | |||
806 | /* Special case: IPv4 duplicate address detection packet (RFC2131) */ | 806 | /* Special case: IPv4 duplicate address detection packet (RFC2131) */ |
807 | if (sip == 0) { | 807 | if (sip == 0) { |
808 | if (arp->ar_op == htons(ARPOP_REQUEST) && | 808 | if (arp->ar_op == htons(ARPOP_REQUEST) && |
809 | inet_addr_type(tip) == RTN_LOCAL && | 809 | inet_addr_type(&init_net, tip) == RTN_LOCAL && |
810 | !arp_ignore(in_dev,dev,sip,tip)) | 810 | !arp_ignore(in_dev,dev,sip,tip)) |
811 | arp_send(ARPOP_REPLY, ETH_P_ARP, sip, dev, tip, sha, | 811 | arp_send(ARPOP_REPLY, ETH_P_ARP, sip, dev, tip, sha, |
812 | dev->dev_addr, sha); | 812 | dev->dev_addr, sha); |
@@ -866,7 +866,7 @@ static int arp_process(struct sk_buff *skb) | |||
866 | */ | 866 | */ |
867 | if (n == NULL && | 867 | if (n == NULL && |
868 | arp->ar_op == htons(ARPOP_REPLY) && | 868 | arp->ar_op == htons(ARPOP_REPLY) && |
869 | inet_addr_type(sip) == RTN_UNICAST) | 869 | inet_addr_type(&init_net, sip) == RTN_UNICAST) |
870 | n = __neigh_lookup(&arp_tbl, &sip, dev, 1); | 870 | n = __neigh_lookup(&arp_tbl, &sip, dev, 1); |
871 | } | 871 | } |
872 | 872 | ||
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 7718823711e..d1a45cb6f6b 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -166,7 +166,8 @@ out: | |||
166 | * Find address type as if only "dev" was present in the system. If | 166 | * Find address type as if only "dev" was present in the system. If |
167 | * on_dev is NULL then all interfaces are taken into consideration. | 167 | * on_dev is NULL then all interfaces are taken into consideration. |
168 | */ | 168 | */ |
169 | static inline unsigned __inet_dev_addr_type(const struct net_device *dev, | 169 | static inline unsigned __inet_dev_addr_type(struct net *net, |
170 | const struct net_device *dev, | ||
170 | __be32 addr) | 171 | __be32 addr) |
171 | { | 172 | { |
172 | struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } }; | 173 | struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } }; |
@@ -183,7 +184,7 @@ static inline unsigned __inet_dev_addr_type(const struct net_device *dev, | |||
183 | res.r = NULL; | 184 | res.r = NULL; |
184 | #endif | 185 | #endif |
185 | 186 | ||
186 | local_table = fib_get_table(&init_net, RT_TABLE_LOCAL); | 187 | local_table = fib_get_table(net, RT_TABLE_LOCAL); |
187 | if (local_table) { | 188 | if (local_table) { |
188 | ret = RTN_UNICAST; | 189 | ret = RTN_UNICAST; |
189 | if (!local_table->tb_lookup(local_table, &fl, &res)) { | 190 | if (!local_table->tb_lookup(local_table, &fl, &res)) { |
@@ -195,14 +196,15 @@ static inline unsigned __inet_dev_addr_type(const struct net_device *dev, | |||
195 | return ret; | 196 | return ret; |
196 | } | 197 | } |
197 | 198 | ||
198 | unsigned int inet_addr_type(__be32 addr) | 199 | unsigned int inet_addr_type(struct net *net, __be32 addr) |
199 | { | 200 | { |
200 | return __inet_dev_addr_type(NULL, addr); | 201 | return __inet_dev_addr_type(net, NULL, addr); |
201 | } | 202 | } |
202 | 203 | ||
203 | unsigned int inet_dev_addr_type(const struct net_device *dev, __be32 addr) | 204 | unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev, |
205 | __be32 addr) | ||
204 | { | 206 | { |
205 | return __inet_dev_addr_type(dev, addr); | 207 | return __inet_dev_addr_type(net, dev, addr); |
206 | } | 208 | } |
207 | 209 | ||
208 | /* Given (packet source, input interface) and optional (dst, oif, tos): | 210 | /* Given (packet source, input interface) and optional (dst, oif, tos): |
@@ -391,7 +393,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt, | |||
391 | if (rt->rt_gateway.sa_family == AF_INET && addr) { | 393 | if (rt->rt_gateway.sa_family == AF_INET && addr) { |
392 | cfg->fc_gw = addr; | 394 | cfg->fc_gw = addr; |
393 | if (rt->rt_flags & RTF_GATEWAY && | 395 | if (rt->rt_flags & RTF_GATEWAY && |
394 | inet_addr_type(addr) == RTN_UNICAST) | 396 | inet_addr_type(&init_net, addr) == RTN_UNICAST) |
395 | cfg->fc_scope = RT_SCOPE_UNIVERSE; | 397 | cfg->fc_scope = RT_SCOPE_UNIVERSE; |
396 | } | 398 | } |
397 | 399 | ||
@@ -782,7 +784,7 @@ static void fib_del_ifaddr(struct in_ifaddr *ifa) | |||
782 | fib_magic(RTM_DELROUTE, RTN_LOCAL, ifa->ifa_local, 32, prim); | 784 | fib_magic(RTM_DELROUTE, RTN_LOCAL, ifa->ifa_local, 32, prim); |
783 | 785 | ||
784 | /* Check, that this local address finally disappeared. */ | 786 | /* Check, that this local address finally disappeared. */ |
785 | if (inet_addr_type(ifa->ifa_local) != RTN_LOCAL) { | 787 | if (inet_addr_type(&init_net, ifa->ifa_local) != RTN_LOCAL) { |
786 | /* And the last, but not the least thing. | 788 | /* And the last, but not the least thing. |
787 | We must flush stray FIB entries. | 789 | We must flush stray FIB entries. |
788 | 790 | ||
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index bbd4a247b19..c1263e23876 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
@@ -531,7 +531,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi, | |||
531 | 531 | ||
532 | if (cfg->fc_scope >= RT_SCOPE_LINK) | 532 | if (cfg->fc_scope >= RT_SCOPE_LINK) |
533 | return -EINVAL; | 533 | return -EINVAL; |
534 | if (inet_addr_type(nh->nh_gw) != RTN_UNICAST) | 534 | if (inet_addr_type(&init_net, nh->nh_gw) != RTN_UNICAST) |
535 | return -EINVAL; | 535 | return -EINVAL; |
536 | if ((dev = __dev_get_by_index(&init_net, nh->nh_oif)) == NULL) | 536 | if ((dev = __dev_get_by_index(&init_net, nh->nh_oif)) == NULL) |
537 | return -ENODEV; | 537 | return -ENODEV; |
@@ -809,7 +809,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg) | |||
809 | if (fi->fib_prefsrc) { | 809 | if (fi->fib_prefsrc) { |
810 | if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst || | 810 | if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst || |
811 | fi->fib_prefsrc != cfg->fc_dst) | 811 | fi->fib_prefsrc != cfg->fc_dst) |
812 | if (inet_addr_type(fi->fib_prefsrc) != RTN_LOCAL) | 812 | if (inet_addr_type(&init_net, fi->fib_prefsrc) != RTN_LOCAL) |
813 | goto err_inval; | 813 | goto err_inval; |
814 | } | 814 | } |
815 | 815 | ||
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 1a6024978e2..e57f1673bf6 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -590,7 +590,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
590 | if (xfrm_decode_session_reverse(skb_in, &fl, AF_INET)) | 590 | if (xfrm_decode_session_reverse(skb_in, &fl, AF_INET)) |
591 | goto out_unlock; | 591 | goto out_unlock; |
592 | 592 | ||
593 | if (inet_addr_type(fl.fl4_src) == RTN_LOCAL) | 593 | if (inet_addr_type(&init_net, fl.fl4_src) == RTN_LOCAL) |
594 | err = __ip_route_output_key(&rt2, &fl); | 594 | err = __ip_route_output_key(&rt2, &fl); |
595 | else { | 595 | else { |
596 | struct flowi fl2 = {}; | 596 | struct flowi fl2 = {}; |
@@ -733,7 +733,7 @@ static void icmp_unreach(struct sk_buff *skb) | |||
733 | */ | 733 | */ |
734 | 734 | ||
735 | if (!sysctl_icmp_ignore_bogus_error_responses && | 735 | if (!sysctl_icmp_ignore_bogus_error_responses && |
736 | inet_addr_type(iph->daddr) == RTN_BROADCAST) { | 736 | inet_addr_type(&init_net, iph->daddr) == RTN_BROADCAST) { |
737 | if (net_ratelimit()) | 737 | if (net_ratelimit()) |
738 | printk(KERN_WARNING "%u.%u.%u.%u sent an invalid ICMP " | 738 | printk(KERN_WARNING "%u.%u.%u.%u sent an invalid ICMP " |
739 | "type %u, code %u " | 739 | "type %u, code %u " |
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index 2f14745a9e1..4d315158fd3 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c | |||
@@ -151,7 +151,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) | |||
151 | __be32 addr; | 151 | __be32 addr; |
152 | 152 | ||
153 | memcpy(&addr, sptr+soffset-1, 4); | 153 | memcpy(&addr, sptr+soffset-1, 4); |
154 | if (inet_addr_type(addr) != RTN_LOCAL) { | 154 | if (inet_addr_type(&init_net, addr) != RTN_LOCAL) { |
155 | dopt->ts_needtime = 1; | 155 | dopt->ts_needtime = 1; |
156 | soffset += 8; | 156 | soffset += 8; |
157 | } | 157 | } |
@@ -400,7 +400,7 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb) | |||
400 | { | 400 | { |
401 | __be32 addr; | 401 | __be32 addr; |
402 | memcpy(&addr, &optptr[optptr[2]-1], 4); | 402 | memcpy(&addr, &optptr[optptr[2]-1], 4); |
403 | if (inet_addr_type(addr) == RTN_UNICAST) | 403 | if (inet_addr_type(&init_net, addr) == RTN_UNICAST) |
404 | break; | 404 | break; |
405 | if (skb) | 405 | if (skb) |
406 | timeptr = (__be32*)&optptr[optptr[2]+3]; | 406 | timeptr = (__be32*)&optptr[optptr[2]+3]; |
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c index 041f5120808..963981a9d50 100644 --- a/net/ipv4/ipvs/ip_vs_core.c +++ b/net/ipv4/ipvs/ip_vs_core.c | |||
@@ -423,7 +423,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, | |||
423 | and the destination is RTN_UNICAST (and not local), then create | 423 | and the destination is RTN_UNICAST (and not local), then create |
424 | a cache_bypass connection entry */ | 424 | a cache_bypass connection entry */ |
425 | if (sysctl_ip_vs_cache_bypass && svc->fwmark | 425 | if (sysctl_ip_vs_cache_bypass && svc->fwmark |
426 | && (inet_addr_type(iph->daddr) == RTN_UNICAST)) { | 426 | && (inet_addr_type(&init_net, iph->daddr) == RTN_UNICAST)) { |
427 | int ret, cs; | 427 | int ret, cs; |
428 | struct ip_vs_conn *cp; | 428 | struct ip_vs_conn *cp; |
429 | 429 | ||
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c index 9fecfe7d116..94c5767c8e0 100644 --- a/net/ipv4/ipvs/ip_vs_ctl.c +++ b/net/ipv4/ipvs/ip_vs_ctl.c | |||
@@ -704,7 +704,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, | |||
704 | conn_flags = udest->conn_flags | IP_VS_CONN_F_INACTIVE; | 704 | conn_flags = udest->conn_flags | IP_VS_CONN_F_INACTIVE; |
705 | 705 | ||
706 | /* check if local node and update the flags */ | 706 | /* check if local node and update the flags */ |
707 | if (inet_addr_type(udest->addr) == RTN_LOCAL) { | 707 | if (inet_addr_type(&init_net, udest->addr) == RTN_LOCAL) { |
708 | conn_flags = (conn_flags & ~IP_VS_CONN_F_FWD_MASK) | 708 | conn_flags = (conn_flags & ~IP_VS_CONN_F_FWD_MASK) |
709 | | IP_VS_CONN_F_LOCALNODE; | 709 | | IP_VS_CONN_F_LOCALNODE; |
710 | } | 710 | } |
@@ -756,7 +756,7 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest, | |||
756 | 756 | ||
757 | EnterFunction(2); | 757 | EnterFunction(2); |
758 | 758 | ||
759 | atype = inet_addr_type(udest->addr); | 759 | atype = inet_addr_type(&init_net, udest->addr); |
760 | if (atype != RTN_LOCAL && atype != RTN_UNICAST) | 760 | if (atype != RTN_LOCAL && atype != RTN_UNICAST) |
761 | return -EINVAL; | 761 | return -EINVAL; |
762 | 762 | ||
diff --git a/net/ipv4/netfilter.c b/net/ipv4/netfilter.c index 4011f8f987c..0ed843ed420 100644 --- a/net/ipv4/netfilter.c +++ b/net/ipv4/netfilter.c | |||
@@ -19,7 +19,7 @@ int ip_route_me_harder(struct sk_buff *skb, unsigned addr_type) | |||
19 | unsigned int hh_len; | 19 | unsigned int hh_len; |
20 | unsigned int type; | 20 | unsigned int type; |
21 | 21 | ||
22 | type = inet_addr_type(iph->saddr); | 22 | type = inet_addr_type(&init_net, iph->saddr); |
23 | if (addr_type == RTN_UNSPEC) | 23 | if (addr_type == RTN_UNSPEC) |
24 | addr_type = type; | 24 | addr_type = type; |
25 | 25 | ||
diff --git a/net/ipv4/netfilter/ipt_addrtype.c b/net/ipv4/netfilter/ipt_addrtype.c index 14394c6a3c2..8763902944b 100644 --- a/net/ipv4/netfilter/ipt_addrtype.c +++ b/net/ipv4/netfilter/ipt_addrtype.c | |||
@@ -26,7 +26,7 @@ MODULE_DESCRIPTION("iptables addrtype match"); | |||
26 | static inline bool match_type(const struct net_device *dev, __be32 addr, | 26 | static inline bool match_type(const struct net_device *dev, __be32 addr, |
27 | u_int16_t mask) | 27 | u_int16_t mask) |
28 | { | 28 | { |
29 | return !!(mask & (1 << inet_dev_addr_type(dev, addr))); | 29 | return !!(mask & (1 << inet_dev_addr_type(&init_net, dev, addr))); |
30 | } | 30 | } |
31 | 31 | ||
32 | static bool | 32 | static bool |
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index e811034b1b0..747911a8241 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
@@ -620,7 +620,7 @@ static int raw_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
620 | 620 | ||
621 | if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in)) | 621 | if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in)) |
622 | goto out; | 622 | goto out; |
623 | chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr); | 623 | chk_addr_ret = inet_addr_type(&init_net, addr->sin_addr.s_addr); |
624 | ret = -EADDRNOTAVAIL; | 624 | ret = -EADDRNOTAVAIL; |
625 | if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL && | 625 | if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL && |
626 | chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST) | 626 | chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST) |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 78c4ce424a6..1e59c0d4b11 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1164,7 +1164,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, | |||
1164 | if (IN_DEV_SEC_REDIRECTS(in_dev) && ip_fib_check_default(new_gw, dev)) | 1164 | if (IN_DEV_SEC_REDIRECTS(in_dev) && ip_fib_check_default(new_gw, dev)) |
1165 | goto reject_redirect; | 1165 | goto reject_redirect; |
1166 | } else { | 1166 | } else { |
1167 | if (inet_addr_type(new_gw) != RTN_UNICAST) | 1167 | if (inet_addr_type(&init_net, new_gw) != RTN_UNICAST) |
1168 | goto reject_redirect; | 1168 | goto reject_redirect; |
1169 | } | 1169 | } |
1170 | 1170 | ||