aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-03-26 05:00:21 -0400
committerDavid S. Miller <davem@davemloft.net>2008-03-26 05:00:21 -0400
commitb34a95ee6e05579faff2672d7d30356576407653 (patch)
tree1587a59fcced1f774193b184301572ee0bc2dda7 /net/ipv4
parent68528f09980a60c8df046d16336333cac4fc0c32 (diff)
[NETNS][ICMP]: Use per-net sysctls in ipv4/icmp.c.
This mostly re-uses the net, used in icmp netnsization patches from Denis. After this ICMP sysctls are completely virtualized. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/icmp.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 958a38445120..7049b3f5f3cc 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -270,7 +270,8 @@ int xrlim_allow(struct dst_entry *dst, int timeout)
270 return rc; 270 return rc;
271} 271}
272 272
273static inline int icmpv4_xrlim_allow(struct rtable *rt, int type, int code) 273static inline int icmpv4_xrlim_allow(struct net *net, struct rtable *rt,
274 int type, int code)
274{ 275{
275 struct dst_entry *dst = &rt->u.dst; 276 struct dst_entry *dst = &rt->u.dst;
276 int rc = 1; 277 int rc = 1;
@@ -287,8 +288,8 @@ static inline int icmpv4_xrlim_allow(struct rtable *rt, int type, int code)
287 goto out; 288 goto out;
288 289
289 /* Limit if icmp type is enabled in ratemask. */ 290 /* Limit if icmp type is enabled in ratemask. */
290 if ((1 << type) & init_net.ipv4.sysctl_icmp_ratemask) 291 if ((1 << type) & net->ipv4.sysctl_icmp_ratemask)
291 rc = xrlim_allow(dst, init_net.ipv4.sysctl_icmp_ratelimit); 292 rc = xrlim_allow(dst, net->ipv4.sysctl_icmp_ratelimit);
292out: 293out:
293 return rc; 294 return rc;
294} 295}
@@ -390,7 +391,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
390 if (ip_route_output_key(net, &rt, &fl)) 391 if (ip_route_output_key(net, &rt, &fl))
391 goto out_unlock; 392 goto out_unlock;
392 } 393 }
393 if (icmpv4_xrlim_allow(rt, icmp_param->data.icmph.type, 394 if (icmpv4_xrlim_allow(net, rt, icmp_param->data.icmph.type,
394 icmp_param->data.icmph.code)) 395 icmp_param->data.icmph.code))
395 icmp_push_reply(icmp_param, &ipc, rt); 396 icmp_push_reply(icmp_param, &ipc, rt);
396 ip_rt_put(rt); 397 ip_rt_put(rt);
@@ -501,7 +502,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
501 struct net_device *dev = NULL; 502 struct net_device *dev = NULL;
502 503
503 if (rt->fl.iif && 504 if (rt->fl.iif &&
504 init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr) 505 net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr)
505 dev = dev_get_by_index(net, rt->fl.iif); 506 dev = dev_get_by_index(net, rt->fl.iif);
506 507
507 if (dev) { 508 if (dev) {
@@ -617,7 +618,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
617 } 618 }
618 619
619route_done: 620route_done:
620 if (!icmpv4_xrlim_allow(rt, type, code)) 621 if (!icmpv4_xrlim_allow(net, rt, type, code))
621 goto ende; 622 goto ende;
622 623
623 /* RFC says return as much as we can without exceeding 576 bytes. */ 624 /* RFC says return as much as we can without exceeding 576 bytes. */
@@ -723,7 +724,7 @@ static void icmp_unreach(struct sk_buff *skb)
723 * get the other vendor to fix their kit. 724 * get the other vendor to fix their kit.
724 */ 725 */
725 726
726 if (!init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses && 727 if (!net->ipv4.sysctl_icmp_ignore_bogus_error_responses &&
727 inet_addr_type(net, iph->daddr) == RTN_BROADCAST) { 728 inet_addr_type(net, iph->daddr) == RTN_BROADCAST) {
728 if (net_ratelimit()) 729 if (net_ratelimit())
729 printk(KERN_WARNING "%u.%u.%u.%u sent an invalid ICMP " 730 printk(KERN_WARNING "%u.%u.%u.%u sent an invalid ICMP "
@@ -818,7 +819,10 @@ out_err:
818 819
819static void icmp_echo(struct sk_buff *skb) 820static void icmp_echo(struct sk_buff *skb)
820{ 821{
821 if (!init_net.ipv4.sysctl_icmp_echo_ignore_all) { 822 struct net *net;
823
824 net = skb->dst->dev->nd_net;
825 if (!net->ipv4.sysctl_icmp_echo_ignore_all) {
822 struct icmp_bxm icmp_param; 826 struct icmp_bxm icmp_param;
823 827
824 icmp_param.data.icmph = *icmp_hdr(skb); 828 icmp_param.data.icmph = *icmp_hdr(skb);
@@ -1021,6 +1025,9 @@ int icmp_rcv(struct sk_buff *skb)
1021 */ 1025 */
1022 1026
1023 if (rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) { 1027 if (rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) {
1028 struct net *net;
1029
1030 net = rt->u.dst.dev->nd_net;
1024 /* 1031 /*
1025 * RFC 1122: 3.2.2.6 An ICMP_ECHO to broadcast MAY be 1032 * RFC 1122: 3.2.2.6 An ICMP_ECHO to broadcast MAY be
1026 * silently ignored (we let user decide with a sysctl). 1033 * silently ignored (we let user decide with a sysctl).
@@ -1029,7 +1036,7 @@ int icmp_rcv(struct sk_buff *skb)
1029 */ 1036 */
1030 if ((icmph->type == ICMP_ECHO || 1037 if ((icmph->type == ICMP_ECHO ||
1031 icmph->type == ICMP_TIMESTAMP) && 1038 icmph->type == ICMP_TIMESTAMP) &&
1032 init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts) { 1039 net->ipv4.sysctl_icmp_echo_ignore_broadcasts) {
1033 goto error; 1040 goto error;
1034 } 1041 }
1035 if (icmph->type != ICMP_ECHO && 1042 if (icmph->type != ICMP_ECHO &&