When L2 interface (e.g VXLAN) pseudo support broadcast, we should make it possible for the user to disable this manually and switch to replicast.
We should preferably find a way to sense this in the code, but if we cannot this feature also useful to manual configuration. Signed-off-by: Hoang Le <[email protected]> --- include/uapi/linux/tipc_netlink.h | 3 ++- net/tipc/bcast.c | 24 ++++++++++++++++++++++-- net/tipc/bcast.h | 2 ++ net/tipc/link.c | 6 ++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/tipc_netlink.h b/include/uapi/linux/tipc_netlink.h index 0ebe02ef1a86..a4a765f69352 100644 --- a/include/uapi/linux/tipc_netlink.h +++ b/include/uapi/linux/tipc_netlink.h @@ -273,7 +273,7 @@ enum { TIPC_NLA_SOCK_STAT_MAX = __TIPC_NLA_SOCK_STAT_MAX - 1 }; -/* Nest, link propreties. Valid for link, media and bearer */ +/* Nest, link properties. Valid for link, media and bearer */ enum { TIPC_NLA_PROP_UNSPEC, @@ -281,6 +281,7 @@ enum { TIPC_NLA_PROP_TOL, /* u32 */ TIPC_NLA_PROP_WIN, /* u32 */ TIPC_NLA_PROP_MTU, /* u32 */ + TIPC_NLA_PROP_BCAST, /* u8 */ __TIPC_NLA_PROP_MAX, TIPC_NLA_PROP_MAX = __TIPC_NLA_PROP_MAX - 1 diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index d8026543bf4c..44acd6957b65 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c @@ -88,6 +88,16 @@ void tipc_bcast_disable_rcast(struct net *net) tipc_bc_base(net)->rcast_support = false; } +bool tipc_bcast_get_bcast(struct net *net) +{ + return tipc_bc_base(net)->bcast_support; +} + +void tipc_bcast_set_bcast(struct net *net, bool sup) +{ + tipc_bc_base(net)->bcast_support = sup; +} + static void tipc_bcbase_calc_bc_threshold(struct net *net) { struct tipc_bc_base *bb = tipc_bc_base(net); @@ -106,7 +116,6 @@ static void tipc_bcbase_select_primary(struct net *net) int i, mtu, prim; bb->primary_bearer = INVALID_BEARER_ID; - bb->bcast_support = true; if (!all_dests) return; @@ -130,7 +139,7 @@ static void tipc_bcbase_select_primary(struct net *net) } prim = bb->primary_bearer; if (prim != INVALID_BEARER_ID) - bb->bcast_support = tipc_bearer_bcast_support(net, prim); + bb->bcast_support &= tipc_bearer_bcast_support(net, prim); } void tipc_bcast_inc_bearer_dst_cnt(struct net *net, int bearer_id) @@ -498,6 +507,16 @@ int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[]) if (err) return err; + if (props[TIPC_NLA_PROP_BCAST]) { + tipc_bcast_lock(net); + if (nla_get_u8(props[TIPC_NLA_PROP_BCAST]) & 0x1) + tipc_bcast_set_bcast(net, true); + else + tipc_bcast_set_bcast(net, false); + tipc_bcast_unlock(net); + return 0; + } + if (!props[TIPC_NLA_PROP_WIN]) return -EOPNOTSUPP; @@ -531,6 +550,7 @@ int tipc_bcast_init(struct net *net) tn->bcl = l; bb->rc_ratio = 25; bb->rcast_support = true; + bb->bcast_support = true; return 0; enomem: kfree(bb); diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h index 751530ab0c49..8880dc595c0b 100644 --- a/net/tipc/bcast.h +++ b/net/tipc/bcast.h @@ -91,6 +91,8 @@ int tipc_bcast_sync_rcv(struct net *net, struct tipc_link *l, int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg); int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[]); int tipc_bclink_reset_stats(struct net *net); +void tipc_bcast_set_bcast(struct net *net, bool sup); +bool tipc_bcast_get_bcast(struct net *net); static inline void tipc_bcast_lock(struct net *net) { diff --git a/net/tipc/link.c b/net/tipc/link.c index ac306d17f8ad..0ac0943b1b00 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -2103,6 +2103,9 @@ int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg, goto prop_msg_full; if (nla_put_u32(msg->skb, TIPC_NLA_PROP_PRIO, link->priority)) goto prop_msg_full; + if (nla_put_u8(msg->skb, TIPC_NLA_PROP_BCAST, + tipc_bearer_bcast_support(net, link->bearer_id))) + goto prop_msg_full; nla_nest_end(msg->skb, prop); err = __tipc_nl_add_stats(msg->skb, &link->stats); @@ -2183,6 +2186,7 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg) struct nlattr *prop; struct tipc_net *tn = net_generic(net, tipc_net_id); struct tipc_link *bcl = tn->bcl; + bool bcast = tipc_bcast_get_bcast(net); if (!bcl) return 0; @@ -2218,6 +2222,8 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg) goto attr_msg_full; if (nla_put_u32(msg->skb, TIPC_NLA_PROP_WIN, bcl->window)) goto prop_msg_full; + if (nla_put_u8(msg->skb, TIPC_NLA_PROP_BCAST, bcast)) + goto prop_msg_full; nla_nest_end(msg->skb, prop); err = __tipc_nl_add_bc_link_stat(msg->skb, &bcl->stats); -- 2.17.1 _______________________________________________ tipc-discussion mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tipc-discussion
