Introduce to configure bearer to indicate it does support
broadcast whether or not.

Signed-off-by: Hoang Le <[email protected]>
---
 include/uapi/linux/tipc_netlink.h |  1 +
 net/tipc/bcast.c                  | 13 +++++++++++--
 net/tipc/bcast.h                  |  2 ++
 net/tipc/bearer.c                 | 16 +++++++++++++---
 net/tipc/netlink.c                |  3 ++-
 5 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/include/uapi/linux/tipc_netlink.h 
b/include/uapi/linux/tipc_netlink.h
index 0ebe02ef1a86..92ecf3cd4013 100644
--- a/include/uapi/linux/tipc_netlink.h
+++ b/include/uapi/linux/tipc_netlink.h
@@ -281,6 +281,7 @@ enum {
        TIPC_NLA_PROP_TOL,              /* u32 */
        TIPC_NLA_PROP_WIN,              /* u32 */
        TIPC_NLA_PROP_MTU,              /* u32 */
+       TIPC_NLA_PROP_BCAST,            /* u32 */
 
        __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..c7b1f619855c 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)
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/bearer.c b/net/tipc/bearer.c
index fb2c0d8f359f..8508ef168a4f 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -676,9 +676,10 @@ void tipc_bearer_stop(struct net *net)
 }
 
 /* Caller should hold rtnl_lock to protect the bearer */
-static int __tipc_nl_add_bearer(struct tipc_nl_msg *msg,
+static int __tipc_nl_add_bearer(struct net *net, struct tipc_nl_msg *msg,
                                struct tipc_bearer *bearer, int nlflags)
 {
+       bool bcast = tipc_bcast_get_bcast(net);
        void *hdr;
        struct nlattr *attrs;
        struct nlattr *prop;
@@ -707,6 +708,8 @@ static int __tipc_nl_add_bearer(struct tipc_nl_msg *msg,
        if (bearer->media->type_id == TIPC_MEDIA_TYPE_UDP)
                if (nla_put_u32(msg->skb, TIPC_NLA_PROP_MTU, bearer->mtu))
                        goto prop_msg_full;
+       if (nla_put_u32(msg->skb, TIPC_NLA_PROP_BCAST, bcast))
+               goto prop_msg_full;
 
        nla_nest_end(msg->skb, prop);
 
@@ -754,7 +757,7 @@ int tipc_nl_bearer_dump(struct sk_buff *skb, struct 
netlink_callback *cb)
                if (!bearer)
                        continue;
 
-               err = __tipc_nl_add_bearer(&msg, bearer, NLM_F_MULTI);
+               err = __tipc_nl_add_bearer(net, &msg, bearer, NLM_F_MULTI);
                if (err)
                        break;
        }
@@ -802,7 +805,7 @@ int tipc_nl_bearer_get(struct sk_buff *skb, struct 
genl_info *info)
                goto err_out;
        }
 
-       err = __tipc_nl_add_bearer(&msg, bearer, 0);
+       err = __tipc_nl_add_bearer(net, &msg, bearer, 0);
        if (err)
                goto err_out;
        rtnl_unlock();
@@ -1006,6 +1009,13 @@ int __tipc_nl_bearer_set(struct sk_buff *skb, struct 
genl_info *info)
                        tipc_node_apply_property(net, b, TIPC_NLA_PROP_MTU);
 #endif
                }
+
+               if (props[TIPC_NLA_PROP_BCAST]) {
+                       if (nla_get_u32(props[TIPC_NLA_PROP_BCAST]) & 0x1)
+                               tipc_bcast_set_bcast(net, true);
+                       else
+                               tipc_bcast_set_bcast(net, false);
+               }
        }
 
        return 0;
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index 99ee419210ba..ca93699b30e2 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -110,7 +110,8 @@ const struct nla_policy 
tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = {
        [TIPC_NLA_PROP_UNSPEC]          = { .type = NLA_UNSPEC },
        [TIPC_NLA_PROP_PRIO]            = { .type = NLA_U32 },
        [TIPC_NLA_PROP_TOL]             = { .type = NLA_U32 },
-       [TIPC_NLA_PROP_WIN]             = { .type = NLA_U32 }
+       [TIPC_NLA_PROP_WIN]             = { .type = NLA_U32 },
+       [TIPC_NLA_PROP_BCAST]           = { .type = NLA_U32 }
 };
 
 const struct nla_policy tipc_nl_bearer_policy[TIPC_NLA_BEARER_MAX + 1] = {
-- 
2.17.1



_______________________________________________
tipc-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tipc-discussion

Reply via email to