Commit dde1bc0e authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[NETNS]: Add namespace for ICMP replying code.

All needed API is done, the namespace is available when required from
the device on the DST entry from the incoming packet. So, just replace
init_net with proper namespace.

Other protocols will follow.
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b5921910
...@@ -405,7 +405,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) ...@@ -405,7 +405,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
.tos = RT_TOS(ip_hdr(skb)->tos) } }, .tos = RT_TOS(ip_hdr(skb)->tos) } },
.proto = IPPROTO_ICMP }; .proto = IPPROTO_ICMP };
security_skb_classify_flow(skb, &fl); security_skb_classify_flow(skb, &fl);
if (ip_route_output_key(&init_net, &rt, &fl)) if (ip_route_output_key(rt->u.dst.dev->nd_net, &rt, &fl))
goto out_unlock; goto out_unlock;
} }
if (icmpv4_xrlim_allow(rt, icmp_param->data.icmph.type, if (icmpv4_xrlim_allow(rt, icmp_param->data.icmph.type,
...@@ -437,9 +437,11 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) ...@@ -437,9 +437,11 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
struct ipcm_cookie ipc; struct ipcm_cookie ipc;
__be32 saddr; __be32 saddr;
u8 tos; u8 tos;
struct net *net;
if (!rt) if (!rt)
goto out; goto out;
net = rt->u.dst.dev->nd_net;
/* /*
* Find the original header. It is expected to be valid, of course. * Find the original header. It is expected to be valid, of course.
...@@ -515,7 +517,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) ...@@ -515,7 +517,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
struct net_device *dev = NULL; struct net_device *dev = NULL;
if (rt->fl.iif && sysctl_icmp_errors_use_inbound_ifaddr) if (rt->fl.iif && sysctl_icmp_errors_use_inbound_ifaddr)
dev = dev_get_by_index(&init_net, rt->fl.iif); dev = dev_get_by_index(net, rt->fl.iif);
if (dev) { if (dev) {
saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK); saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK);
...@@ -569,7 +571,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) ...@@ -569,7 +571,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
struct rtable *rt2; struct rtable *rt2;
security_skb_classify_flow(skb_in, &fl); security_skb_classify_flow(skb_in, &fl);
if (__ip_route_output_key(&init_net, &rt, &fl)) if (__ip_route_output_key(net, &rt, &fl))
goto out_unlock; goto out_unlock;
/* No need to clone since we're just using its address. */ /* No need to clone since we're just using its address. */
...@@ -591,14 +593,14 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) ...@@ -591,14 +593,14 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
if (xfrm_decode_session_reverse(skb_in, &fl, AF_INET)) if (xfrm_decode_session_reverse(skb_in, &fl, AF_INET))
goto out_unlock; goto out_unlock;
if (inet_addr_type(&init_net, fl.fl4_src) == RTN_LOCAL) if (inet_addr_type(net, fl.fl4_src) == RTN_LOCAL)
err = __ip_route_output_key(&init_net, &rt2, &fl); err = __ip_route_output_key(net, &rt2, &fl);
else { else {
struct flowi fl2 = {}; struct flowi fl2 = {};
struct dst_entry *odst; struct dst_entry *odst;
fl2.fl4_dst = fl.fl4_src; fl2.fl4_dst = fl.fl4_src;
if (ip_route_output_key(&init_net, &rt2, &fl2)) if (ip_route_output_key(net, &rt2, &fl2))
goto out_unlock; goto out_unlock;
/* Ugh! */ /* Ugh! */
...@@ -666,6 +668,9 @@ static void icmp_unreach(struct sk_buff *skb) ...@@ -666,6 +668,9 @@ static void icmp_unreach(struct sk_buff *skb)
int hash, protocol; int hash, protocol;
struct net_protocol *ipprot; struct net_protocol *ipprot;
u32 info = 0; u32 info = 0;
struct net *net;
net = skb->dst->dev->nd_net;
/* /*
* Incomplete header ? * Incomplete header ?
...@@ -696,7 +701,7 @@ static void icmp_unreach(struct sk_buff *skb) ...@@ -696,7 +701,7 @@ static void icmp_unreach(struct sk_buff *skb)
"and DF set.\n", "and DF set.\n",
NIPQUAD(iph->daddr)); NIPQUAD(iph->daddr));
} else { } else {
info = ip_rt_frag_needed(&init_net, iph, info = ip_rt_frag_needed(net, iph,
ntohs(icmph->un.frag.mtu)); ntohs(icmph->un.frag.mtu));
if (!info) if (!info)
goto out; goto out;
...@@ -734,7 +739,7 @@ static void icmp_unreach(struct sk_buff *skb) ...@@ -734,7 +739,7 @@ static void icmp_unreach(struct sk_buff *skb)
*/ */
if (!sysctl_icmp_ignore_bogus_error_responses && if (!sysctl_icmp_ignore_bogus_error_responses &&
inet_addr_type(&init_net, iph->daddr) == RTN_BROADCAST) { inet_addr_type(net, iph->daddr) == RTN_BROADCAST) {
if (net_ratelimit()) if (net_ratelimit())
printk(KERN_WARNING "%u.%u.%u.%u sent an invalid ICMP " printk(KERN_WARNING "%u.%u.%u.%u sent an invalid ICMP "
"type %u, code %u " "type %u, code %u "
......
...@@ -1379,7 +1379,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar ...@@ -1379,7 +1379,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
.dport = tcp_hdr(skb)->source } }, .dport = tcp_hdr(skb)->source } },
.proto = sk->sk_protocol }; .proto = sk->sk_protocol };
security_skb_classify_flow(skb, &fl); security_skb_classify_flow(skb, &fl);
if (ip_route_output_key(&init_net, &rt, &fl)) if (ip_route_output_key(sk->sk_net, &rt, &fl))
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment