Skip to content

Commit 1e9ca45

Browse files
Nikolay Aleksandrovdavem330
authored andcommitted
net: bridge: multicast: include router port vlan id in notifications
Use the port multicast context to check if the router port is a vlan and in case it is include its vlan id in the notification. Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 615cc23 commit 1e9ca45

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

include/uapi/linux/if_bridge.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ enum {
629629
MDBA_ROUTER_PATTR_TYPE,
630630
MDBA_ROUTER_PATTR_INET_TIMER,
631631
MDBA_ROUTER_PATTR_INET6_TIMER,
632+
MDBA_ROUTER_PATTR_VID,
632633
__MDBA_ROUTER_PATTR_MAX
633634
};
634635
#define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1)

net/bridge/br_mdb.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -781,12 +781,12 @@ void br_mdb_notify(struct net_device *dev,
781781

782782
static int nlmsg_populate_rtr_fill(struct sk_buff *skb,
783783
struct net_device *dev,
784-
int ifindex, u32 pid,
784+
int ifindex, u16 vid, u32 pid,
785785
u32 seq, int type, unsigned int flags)
786786
{
787+
struct nlattr *nest, *port_nest;
787788
struct br_port_msg *bpm;
788789
struct nlmsghdr *nlh;
789-
struct nlattr *nest;
790790

791791
nlh = nlmsg_put(skb, pid, seq, type, sizeof(*bpm), 0);
792792
if (!nlh)
@@ -800,8 +800,18 @@ static int nlmsg_populate_rtr_fill(struct sk_buff *skb,
800800
if (!nest)
801801
goto cancel;
802802

803-
if (nla_put_u32(skb, MDBA_ROUTER_PORT, ifindex))
803+
port_nest = nla_nest_start_noflag(skb, MDBA_ROUTER_PORT);
804+
if (!port_nest)
805+
goto end;
806+
if (nla_put_nohdr(skb, sizeof(u32), &ifindex)) {
807+
nla_nest_cancel(skb, port_nest);
804808
goto end;
809+
}
810+
if (vid && nla_put_u16(skb, MDBA_ROUTER_PATTR_VID, vid)) {
811+
nla_nest_cancel(skb, port_nest);
812+
goto end;
813+
}
814+
nla_nest_end(skb, port_nest);
805815

806816
nla_nest_end(skb, nest);
807817
nlmsg_end(skb, nlh);
@@ -817,23 +827,28 @@ static int nlmsg_populate_rtr_fill(struct sk_buff *skb,
817827
static inline size_t rtnl_rtr_nlmsg_size(void)
818828
{
819829
return NLMSG_ALIGN(sizeof(struct br_port_msg))
820-
+ nla_total_size(sizeof(__u32));
830+
+ nla_total_size(sizeof(__u32))
831+
+ nla_total_size(sizeof(u16));
821832
}
822833

823-
void br_rtr_notify(struct net_device *dev, struct net_bridge_port *port,
834+
void br_rtr_notify(struct net_device *dev, struct net_bridge_mcast_port *pmctx,
824835
int type)
825836
{
826837
struct net *net = dev_net(dev);
827838
struct sk_buff *skb;
828839
int err = -ENOBUFS;
829840
int ifindex;
841+
u16 vid;
830842

831-
ifindex = port ? port->dev->ifindex : 0;
843+
ifindex = pmctx ? pmctx->port->dev->ifindex : 0;
844+
vid = pmctx && br_multicast_port_ctx_is_vlan(pmctx) ? pmctx->vlan->vid :
845+
0;
832846
skb = nlmsg_new(rtnl_rtr_nlmsg_size(), GFP_ATOMIC);
833847
if (!skb)
834848
goto errout;
835849

836-
err = nlmsg_populate_rtr_fill(skb, dev, ifindex, 0, 0, type, NTF_SELF);
850+
err = nlmsg_populate_rtr_fill(skb, dev, ifindex, vid, 0, 0, type,
851+
NTF_SELF);
837852
if (err < 0) {
838853
kfree_skb(skb);
839854
goto errout;

net/bridge/br_multicast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2979,7 +2979,7 @@ static void br_multicast_add_router(struct net_bridge_mcast *brmctx,
29792979
* IPv4 or IPv6 multicast router.
29802980
*/
29812981
if (br_multicast_no_router_otherpf(pmctx, rlist)) {
2982-
br_rtr_notify(pmctx->port->br->dev, pmctx->port, RTM_NEWMDB);
2982+
br_rtr_notify(pmctx->port->br->dev, pmctx, RTM_NEWMDB);
29832983
br_port_mc_router_state_change(pmctx->port, true);
29842984
}
29852985
}
@@ -4078,7 +4078,7 @@ br_multicast_rport_del_notify(struct net_bridge_mcast_port *pmctx, bool deleted)
40784078
return;
40794079
#endif
40804080

4081-
br_rtr_notify(pmctx->port->br->dev, pmctx->port, RTM_DELMDB);
4081+
br_rtr_notify(pmctx->port->br->dev, pmctx, RTM_DELMDB);
40824082
br_port_mc_router_state_change(pmctx->port, false);
40834083

40844084
/* don't allow timer refresh */

net/bridge/br_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ int br_mdb_hash_init(struct net_bridge *br);
872872
void br_mdb_hash_fini(struct net_bridge *br);
873873
void br_mdb_notify(struct net_device *dev, struct net_bridge_mdb_entry *mp,
874874
struct net_bridge_port_group *pg, int type);
875-
void br_rtr_notify(struct net_device *dev, struct net_bridge_port *port,
875+
void br_rtr_notify(struct net_device *dev, struct net_bridge_mcast_port *pmctx,
876876
int type);
877877
void br_multicast_del_pg(struct net_bridge_mdb_entry *mp,
878878
struct net_bridge_port_group *pg,

0 commit comments

Comments
 (0)