Skip to content

Commit d01332f

Browse files
Richard Alpedavem330
authored andcommitted
tipc: fix link attribute propagation bug
Changing certain link attributes (link tolerance and link priority) from the TIPC management tool is supposed to automatically take effect at both endpoints of the affected link. Currently the media address is not instantiated for the link and is used uninstantiated when crafting protocol messages designated for the peer endpoint. This means that changing a link property currently results in the property being changed on the local machine but the protocol message designated for the peer gets lost. Resulting in property discrepancy between the endpoints. In this patch we resolve this by using the media address from the link entry and using the bearer transmit function to send it. Hence, we can now eliminate the redundant function tipc_link_prot_xmit() and the redundant field tipc_link::media_addr. Fixes: 2af5ae3 (tipc: clean up unused code and structures) Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Reported-by: Jason Hu <huzhijiang@gmail.com> Signed-off-by: Richard Alpe <richard.alpe@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6247fd9 commit d01332f

File tree

3 files changed

+16
-30
lines changed

3 files changed

+16
-30
lines changed

net/tipc/link.c

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ struct tipc_stats {
123123
struct tipc_link {
124124
u32 addr;
125125
char name[TIPC_MAX_LINK_NAME];
126-
struct tipc_media_addr *media_addr;
127126
struct net *net;
128127

129128
/* Management and link supervision data */
@@ -1261,26 +1260,6 @@ int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb,
12611260
return rc;
12621261
}
12631262

1264-
/*
1265-
* Send protocol message to the other endpoint.
1266-
*/
1267-
static void tipc_link_proto_xmit(struct tipc_link *l, u32 msg_typ,
1268-
int probe_msg, u32 gap, u32 tolerance,
1269-
u32 priority)
1270-
{
1271-
struct sk_buff *skb = NULL;
1272-
struct sk_buff_head xmitq;
1273-
1274-
__skb_queue_head_init(&xmitq);
1275-
tipc_link_build_proto_msg(l, msg_typ, probe_msg, gap,
1276-
tolerance, priority, &xmitq);
1277-
skb = __skb_dequeue(&xmitq);
1278-
if (!skb)
1279-
return;
1280-
tipc_bearer_xmit_skb(l->net, l->bearer_id, skb, l->media_addr);
1281-
l->rcv_unacked = 0;
1282-
}
1283-
12841263
static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
12851264
u16 rcvgap, int tolerance, int priority,
12861265
struct sk_buff_head *xmitq)
@@ -2021,16 +2000,18 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg)
20212000
return -EMSGSIZE;
20222001
}
20232002

2024-
void tipc_link_set_tolerance(struct tipc_link *l, u32 tol)
2003+
void tipc_link_set_tolerance(struct tipc_link *l, u32 tol,
2004+
struct sk_buff_head *xmitq)
20252005
{
20262006
l->tolerance = tol;
2027-
tipc_link_proto_xmit(l, STATE_MSG, 0, 0, tol, 0);
2007+
tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, tol, 0, xmitq);
20282008
}
20292009

2030-
void tipc_link_set_prio(struct tipc_link *l, u32 prio)
2010+
void tipc_link_set_prio(struct tipc_link *l, u32 prio,
2011+
struct sk_buff_head *xmitq)
20312012
{
20322013
l->priority = prio;
2033-
tipc_link_proto_xmit(l, STATE_MSG, 0, 0, 0, prio);
2014+
tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, prio, xmitq);
20342015
}
20352016

20362017
void tipc_link_set_abort_limit(struct tipc_link *l, u32 limit)

net/tipc/link.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ char tipc_link_plane(struct tipc_link *l);
112112
int tipc_link_prio(struct tipc_link *l);
113113
int tipc_link_window(struct tipc_link *l);
114114
unsigned long tipc_link_tolerance(struct tipc_link *l);
115-
void tipc_link_set_tolerance(struct tipc_link *l, u32 tol);
116-
void tipc_link_set_prio(struct tipc_link *l, u32 prio);
115+
void tipc_link_set_tolerance(struct tipc_link *l, u32 tol,
116+
struct sk_buff_head *xmitq);
117+
void tipc_link_set_prio(struct tipc_link *l, u32 prio,
118+
struct sk_buff_head *xmitq);
117119
void tipc_link_set_abort_limit(struct tipc_link *l, u32 limit);
118120
void tipc_link_set_queue_limits(struct tipc_link *l, u32 window);
119121
int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,

net/tipc/node.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,9 +1637,12 @@ int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info)
16371637
char *name;
16381638
struct tipc_link *link;
16391639
struct tipc_node *node;
1640+
struct sk_buff_head xmitq;
16401641
struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1];
16411642
struct net *net = sock_net(skb->sk);
16421643

1644+
__skb_queue_head_init(&xmitq);
1645+
16431646
if (!info->attrs[TIPC_NLA_LINK])
16441647
return -EINVAL;
16451648

@@ -1683,13 +1686,13 @@ int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info)
16831686
u32 tol;
16841687

16851688
tol = nla_get_u32(props[TIPC_NLA_PROP_TOL]);
1686-
tipc_link_set_tolerance(link, tol);
1689+
tipc_link_set_tolerance(link, tol, &xmitq);
16871690
}
16881691
if (props[TIPC_NLA_PROP_PRIO]) {
16891692
u32 prio;
16901693

16911694
prio = nla_get_u32(props[TIPC_NLA_PROP_PRIO]);
1692-
tipc_link_set_prio(link, prio);
1695+
tipc_link_set_prio(link, prio, &xmitq);
16931696
}
16941697
if (props[TIPC_NLA_PROP_WIN]) {
16951698
u32 win;
@@ -1701,7 +1704,7 @@ int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info)
17011704

17021705
out:
17031706
tipc_node_read_unlock(node);
1704-
1707+
tipc_bearer_xmit(net, bearer_id, &xmitq, &node->links[bearer_id].maddr);
17051708
return res;
17061709
}
17071710

0 commit comments

Comments
 (0)