Skip to content

Commit 60d9b03

Browse files
dsaherndavem330
authored andcommitted
net: ipv4: add second dif to multicast source filter
Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6735993 commit 60d9b03

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

include/linux/igmp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ extern int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
118118
struct ip_msfilter __user *optval, int __user *optlen);
119119
extern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
120120
struct group_filter __user *optval, int __user *optlen);
121-
extern int ip_mc_sf_allow(struct sock *sk, __be32 local, __be32 rmt, int dif);
121+
extern int ip_mc_sf_allow(struct sock *sk, __be32 local, __be32 rmt,
122+
int dif, int sdif);
122123
extern void ip_mc_init_dev(struct in_device *);
123124
extern void ip_mc_destroy_dev(struct in_device *);
124125
extern void ip_mc_up(struct in_device *);

net/ipv4/igmp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,7 +2549,8 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
25492549
/*
25502550
* check if a multicast source filter allows delivery for a given <src,dst,intf>
25512551
*/
2552-
int ip_mc_sf_allow(struct sock *sk, __be32 loc_addr, __be32 rmt_addr, int dif)
2552+
int ip_mc_sf_allow(struct sock *sk, __be32 loc_addr, __be32 rmt_addr,
2553+
int dif, int sdif)
25532554
{
25542555
struct inet_sock *inet = inet_sk(sk);
25552556
struct ip_mc_socklist *pmc;
@@ -2564,7 +2565,8 @@ int ip_mc_sf_allow(struct sock *sk, __be32 loc_addr, __be32 rmt_addr, int dif)
25642565
rcu_read_lock();
25652566
for_each_pmc_rcu(inet, pmc) {
25662567
if (pmc->multi.imr_multiaddr.s_addr == loc_addr &&
2567-
pmc->multi.imr_ifindex == dif)
2568+
(pmc->multi.imr_ifindex == dif ||
2569+
(sdif && pmc->multi.imr_ifindex == sdif)))
25682570
break;
25692571
}
25702572
ret = inet->mc_all;

net/ipv4/raw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
193193
delivered = 1;
194194
if ((iph->protocol != IPPROTO_ICMP || !icmp_filter(sk, skb)) &&
195195
ip_mc_sf_allow(sk, iph->daddr, iph->saddr,
196-
skb->dev->ifindex)) {
196+
skb->dev->ifindex, sdif)) {
197197
struct sk_buff *clone = skb_clone(skb, GFP_ATOMIC);
198198

199199
/* Not releasing hash table! */

net/ipv4/udp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ static inline bool __udp_is_mcast_sock(struct net *net, struct sock *sk,
606606
(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif &&
607607
sk->sk_bound_dev_if != sdif))
608608
return false;
609-
if (!ip_mc_sf_allow(sk, loc_addr, rmt_addr, dif))
609+
if (!ip_mc_sf_allow(sk, loc_addr, rmt_addr, dif, sdif))
610610
return false;
611611
return true;
612612
}

0 commit comments

Comments
 (0)