diff options
| author | Stephen Suryaputra <ssuryaextr@gmail.com> | 2019-03-19 12:37:12 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2019-03-19 17:29:51 -0400 |
| commit | 03f1eccc7a69c965351e6bee41c62afa2844752f (patch) | |
| tree | f2fdd622b6aada216a68de153f01fd4e252ba1a7 /net/ipv6 | |
| parent | f9cb75970e7b61e7f0c14dacf709f830b6bf21e8 (diff) | |
ipv6: Add icmp_echo_ignore_multicast support for ICMPv6
IPv4 has icmp_echo_ignore_broadcast to prevent responding to broadcast pings.
IPv6 needs a similar mechanism.
v1->v2:
- Remove NET_IPV6_ICMP_ECHO_IGNORE_MULTICAST.
Signed-off-by: Stephen Suryaputra <ssuryaextr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
| -rw-r--r-- | net/ipv6/af_inet6.c | 1 | ||||
| -rw-r--r-- | net/ipv6/icmp.c | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 2f45d2a3e3a3..fdc117de849c 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
| @@ -847,6 +847,7 @@ static int __net_init inet6_net_init(struct net *net) | |||
| 847 | net->ipv6.sysctl.bindv6only = 0; | 847 | net->ipv6.sysctl.bindv6only = 0; |
| 848 | net->ipv6.sysctl.icmpv6_time = 1*HZ; | 848 | net->ipv6.sysctl.icmpv6_time = 1*HZ; |
| 849 | net->ipv6.sysctl.icmpv6_echo_ignore_all = 0; | 849 | net->ipv6.sysctl.icmpv6_echo_ignore_all = 0; |
| 850 | net->ipv6.sysctl.icmpv6_echo_ignore_multicast = 0; | ||
| 850 | net->ipv6.sysctl.flowlabel_consistency = 1; | 851 | net->ipv6.sysctl.flowlabel_consistency = 1; |
| 851 | net->ipv6.sysctl.auto_flowlabels = IP6_DEFAULT_AUTO_FLOW_LABELS; | 852 | net->ipv6.sysctl.auto_flowlabels = IP6_DEFAULT_AUTO_FLOW_LABELS; |
| 852 | net->ipv6.sysctl.idgen_retries = 3; | 853 | net->ipv6.sysctl.idgen_retries = 3; |
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 802faa2fcc0e..0907bcede5e5 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
| @@ -684,6 +684,10 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
| 684 | struct ipcm6_cookie ipc6; | 684 | struct ipcm6_cookie ipc6; |
| 685 | u32 mark = IP6_REPLY_MARK(net, skb->mark); | 685 | u32 mark = IP6_REPLY_MARK(net, skb->mark); |
| 686 | 686 | ||
| 687 | if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) && | ||
| 688 | net->ipv6.sysctl.icmpv6_echo_ignore_multicast) | ||
| 689 | return; | ||
| 690 | |||
| 687 | saddr = &ipv6_hdr(skb)->daddr; | 691 | saddr = &ipv6_hdr(skb)->daddr; |
| 688 | 692 | ||
| 689 | if (!ipv6_unicast_destination(skb) && | 693 | if (!ipv6_unicast_destination(skb) && |
| @@ -1115,6 +1119,13 @@ static struct ctl_table ipv6_icmp_table_template[] = { | |||
| 1115 | .mode = 0644, | 1119 | .mode = 0644, |
| 1116 | .proc_handler = proc_dointvec, | 1120 | .proc_handler = proc_dointvec, |
| 1117 | }, | 1121 | }, |
| 1122 | { | ||
| 1123 | .procname = "echo_ignore_multicast", | ||
| 1124 | .data = &init_net.ipv6.sysctl.icmpv6_echo_ignore_multicast, | ||
| 1125 | .maxlen = sizeof(int), | ||
| 1126 | .mode = 0644, | ||
| 1127 | .proc_handler = proc_dointvec, | ||
| 1128 | }, | ||
| 1118 | { }, | 1129 | { }, |
| 1119 | }; | 1130 | }; |
| 1120 | 1131 | ||
| @@ -1129,6 +1140,7 @@ struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net) | |||
| 1129 | if (table) { | 1140 | if (table) { |
| 1130 | table[0].data = &net->ipv6.sysctl.icmpv6_time; | 1141 | table[0].data = &net->ipv6.sysctl.icmpv6_time; |
| 1131 | table[1].data = &net->ipv6.sysctl.icmpv6_echo_ignore_all; | 1142 | table[1].data = &net->ipv6.sysctl.icmpv6_echo_ignore_all; |
| 1143 | table[2].data = &net->ipv6.sysctl.icmpv6_echo_ignore_multicast; | ||
| 1132 | } | 1144 | } |
| 1133 | return table; | 1145 | return table; |
| 1134 | } | 1146 | } |
