aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorAndrew McDonald <andrew@mcdonald.org.uk>2005-08-09 22:44:42 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2005-08-29 18:37:06 -0400
commit0bd1b59b15e4057101c89d4db15a3683c0d897f7 (patch)
tree1912652fdf55f1bcc703ae9a3dcb93036dcfca67 /net/ipv6
parent7af4cc3fa158ff1dda6e7451c7e6afa6b0bb85cb (diff)
[IPV6]: Check interface bindings on IPv6 raw socket reception
Take account of whether a socket is bound to a particular device when selecting an IPv6 raw socket to receive a packet. Also perform this check when receiving IPv6 packets with router alert options. Signed-off-by: Andrew McDonald <andrew@mcdonald.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/icmp.c3
-rw-r--r--net/ipv6/ip6_output.c4
-rw-r--r--net/ipv6/raw.c11
3 files changed, 13 insertions, 5 deletions
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index ff3ec9822e36..ee9f1d36346c 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -551,7 +551,8 @@ static void icmpv6_notify(struct sk_buff *skb, int type, int code, u32 info)
551 551
552 read_lock(&raw_v6_lock); 552 read_lock(&raw_v6_lock);
553 if ((sk = sk_head(&raw_v6_htable[hash])) != NULL) { 553 if ((sk = sk_head(&raw_v6_htable[hash])) != NULL) {
554 while((sk = __raw_v6_lookup(sk, nexthdr, daddr, saddr))) { 554 while((sk = __raw_v6_lookup(sk, nexthdr, daddr, saddr,
555 skb->dev->ifindex))) {
555 rawv6_err(sk, skb, NULL, type, code, inner_offset, info); 556 rawv6_err(sk, skb, NULL, type, code, inner_offset, info);
556 sk = sk_next(sk); 557 sk = sk_next(sk);
557 } 558 }
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index a7fcbcc83576..00f85148b85f 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -277,7 +277,9 @@ static int ip6_call_ra_chain(struct sk_buff *skb, int sel)
277 read_lock(&ip6_ra_lock); 277 read_lock(&ip6_ra_lock);
278 for (ra = ip6_ra_chain; ra; ra = ra->next) { 278 for (ra = ip6_ra_chain; ra; ra = ra->next) {
279 struct sock *sk = ra->sk; 279 struct sock *sk = ra->sk;
280 if (sk && ra->sel == sel) { 280 if (sk && ra->sel == sel &&
281 (!sk->sk_bound_dev_if ||
282 sk->sk_bound_dev_if == skb->dev->ifindex)) {
281 if (last) { 283 if (last) {
282 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); 284 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
283 if (skb2) 285 if (skb2)
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 1d4d75b34d32..9db0de81f074 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -81,7 +81,8 @@ static void raw_v6_unhash(struct sock *sk)
81 81
82/* Grumble... icmp and ip_input want to get at this... */ 82/* Grumble... icmp and ip_input want to get at this... */
83struct sock *__raw_v6_lookup(struct sock *sk, unsigned short num, 83struct sock *__raw_v6_lookup(struct sock *sk, unsigned short num,
84 struct in6_addr *loc_addr, struct in6_addr *rmt_addr) 84 struct in6_addr *loc_addr, struct in6_addr *rmt_addr,
85 int dif)
85{ 86{
86 struct hlist_node *node; 87 struct hlist_node *node;
87 int is_multicast = ipv6_addr_is_multicast(loc_addr); 88 int is_multicast = ipv6_addr_is_multicast(loc_addr);
@@ -94,6 +95,9 @@ struct sock *__raw_v6_lookup(struct sock *sk, unsigned short num,
94 !ipv6_addr_equal(&np->daddr, rmt_addr)) 95 !ipv6_addr_equal(&np->daddr, rmt_addr))
95 continue; 96 continue;
96 97
98 if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)
99 continue;
100
97 if (!ipv6_addr_any(&np->rcv_saddr)) { 101 if (!ipv6_addr_any(&np->rcv_saddr)) {
98 if (ipv6_addr_equal(&np->rcv_saddr, loc_addr)) 102 if (ipv6_addr_equal(&np->rcv_saddr, loc_addr))
99 goto found; 103 goto found;
@@ -160,7 +164,7 @@ void ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
160 if (sk == NULL) 164 if (sk == NULL)
161 goto out; 165 goto out;
162 166
163 sk = __raw_v6_lookup(sk, nexthdr, daddr, saddr); 167 sk = __raw_v6_lookup(sk, nexthdr, daddr, saddr, skb->dev->ifindex);
164 168
165 while (sk) { 169 while (sk) {
166 if (nexthdr != IPPROTO_ICMPV6 || !icmpv6_filter(sk, skb)) { 170 if (nexthdr != IPPROTO_ICMPV6 || !icmpv6_filter(sk, skb)) {
@@ -170,7 +174,8 @@ void ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
170 if (clone) 174 if (clone)
171 rawv6_rcv(sk, clone); 175 rawv6_rcv(sk, clone);
172 } 176 }
173 sk = __raw_v6_lookup(sk_next(sk), nexthdr, daddr, saddr); 177 sk = __raw_v6_lookup(sk_next(sk), nexthdr, daddr, saddr,
178 skb->dev->ifindex);
174 } 179 }
175out: 180out:
176 read_unlock(&raw_v6_lock); 181 read_unlock(&raw_v6_lock);