On 02/10/2018 01:07 AM, Jon Maloy wrote:
> Currently, the default link tolerance set in bearer only has effect
> on links going up after that moment. I.e., a user has to reset all
> the node's links across the bearer to have the new value applied.
> This is too limiting and disturbing on a running cluster to be useful.
>
> We now change this so that also already existing links are updated
> dynamically, without any need for a reset, when the bearer value is
> changed. We leverage the already existing per-link functionality
> for this to achieve the wanted effect.
>
> Signed-off-by: Jon Maloy <[email protected]>
> ---
> net/tipc/bearer.c | 12 ++++++++----
> net/tipc/link.c | 3 ++-
> net/tipc/node.c | 23 +++++++++++++++++++++++
> net/tipc/node.h | 1 +
> 4 files changed, 34 insertions(+), 5 deletions(-)
>
> diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
> index c800147..4a411fef 100644
> --- a/net/tipc/bearer.c
> +++ b/net/tipc/bearer.c
> @@ -946,11 +946,12 @@ int tipc_nl_bearer_add(struct sk_buff *skb, struct
> genl_info *info)
>
> int tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)
> {
> - int err;
> - char *name;
> struct tipc_bearer *b;
> struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1];
> struct net *net = sock_net(skb->sk);
> + char *name;
> + int err;
> + u32 tol;
>
> if (!info->attrs[TIPC_NLA_BEARER])
> return -EINVAL;
> @@ -982,8 +983,11 @@ int tipc_nl_bearer_set(struct sk_buff *skb, struct
> genl_info *info)
> return err;
> }
>
> - if (props[TIPC_NLA_PROP_TOL])
> - b->tolerance = nla_get_u32(props[TIPC_NLA_PROP_TOL]);
> + if (props[TIPC_NLA_PROP_TOL]) {
> + tol = nla_get_u32(props[TIPC_NLA_PROP_TOL]);
> + b->tolerance = tol;
> + tipc_node_set_tolerances(net, b->identity, tol);
It seems unnecessary to introduce "tol" variable, instead we can do this:
if (props[TIPC_NLA_PROP_TOL]) {
b->tolerance = nla_get_u32(props[TIPC_NLA_PROP_TOL]);
tipc_node_set_tolerances(net, b);
}
Meanwhile, we can change tipc_node_set_tolerances() prototype as below:
tipc_node_set_tolerances(struct net *net, struct tipc_bearer *b)
> + }
> if (props[TIPC_NLA_PROP_PRIO])
> b->priority = nla_get_u32(props[TIPC_NLA_PROP_PRIO]);
> if (props[TIPC_NLA_PROP_WIN])
> diff --git a/net/tipc/link.c b/net/tipc/link.c
> index 2d6b2ae..3c23046 100644
> --- a/net/tipc/link.c
> +++ b/net/tipc/link.c
> @@ -2126,7 +2126,8 @@ void tipc_link_set_tolerance(struct tipc_link *l, u32
> tol,
> struct sk_buff_head *xmitq)
> {
> l->tolerance = tol;
> - tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, tol, 0, xmitq);
> + if (link_is_up(l))
> + tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, tol, 0, xmitq);
> }
>
> void tipc_link_set_prio(struct tipc_link *l, u32 prio,
> diff --git a/net/tipc/node.c b/net/tipc/node.c
> index 9036d87..697064c 100644
> --- a/net/tipc/node.c
> +++ b/net/tipc/node.c
> @@ -1618,6 +1618,29 @@ void tipc_rcv(struct net *net, struct sk_buff *skb,
> struct tipc_bearer *b)
> kfree_skb(skb);
> }
>
> +void tipc_node_set_tolerances(struct net *net, int bearer_id, u32 tolerance)
> +{
> + struct tipc_net *tn = tipc_net(net);
> + struct sk_buff_head xmitq;
> + struct tipc_link_entry *e;
> + struct tipc_node *n;
> +
> + __skb_queue_head_init(&xmitq);
> +
> + rcu_read_lock();
> +
> + list_for_each_entry_rcu(n, &tn->node_list, list) {
> + tipc_node_write_lock(n);
> + e = &n->links[bearer_id];
> + if (e->link)
> + tipc_link_set_tolerance(e->link, tolerance, &xmitq);
> + tipc_node_write_unlock(n);
> + tipc_bearer_xmit(net, bearer_id, &xmitq, &e->maddr);
> + }
> +
> + rcu_read_unlock();
> +}
> +
> int tipc_nl_peer_rm(struct sk_buff *skb, struct genl_info *info)
> {
> struct net *net = sock_net(skb->sk);
> diff --git a/net/tipc/node.h b/net/tipc/node.h
> index acd58d2..7e38bcc 100644
> --- a/net/tipc/node.h
> +++ b/net/tipc/node.h
> @@ -65,6 +65,7 @@ void tipc_node_check_dest(struct net *net, u32 onode,
> struct tipc_media_addr *maddr,
> bool *respond, bool *dupl_addr);
> void tipc_node_delete_links(struct net *net, int bearer_id);
> +void tipc_node_set_tolerances(struct net *net, int bearer_id, u32 tolerance);
> int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 node,
> char *linkname, size_t len);
> int tipc_node_xmit(struct net *net, struct sk_buff_head *list, u32 dnode,
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
tipc-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tipc-discussion