Skip to content

Commit 23d8335

Browse files
Jon Paul Maloydavem330
authored andcommitted
tipc: remove implicit message delivery in node_unlock()
After the most recent changes, all access calls to a link which may entail addition of messages to the link's input queue are postpended by an explicit call to tipc_sk_rcv(), using a reference to the correct queue. This means that the potentially hazardous implicit delivery, using tipc_node_unlock() in combination with a binary flag and a cached queue pointer, now has become redundant. This commit removes this implicit delivery mechanism both for regular data messages and for binding table update messages. Tested-by: Ying Xue <[email protected]> Signed-off-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 598411d commit 23d8335

File tree

4 files changed

+10
-63
lines changed

4 files changed

+10
-63
lines changed

net/tipc/link.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,6 @@ void link_prepare_wakeup(struct tipc_link *l)
559559
break;
560560
skb_unlink(skb, &l->wakeupq);
561561
skb_queue_tail(l->inputq, skb);
562-
l->owner->inputq = l->inputq;
563-
l->owner->action_flags |= TIPC_MSG_EVT;
564562
}
565563
}
566564

@@ -598,8 +596,6 @@ void tipc_link_purge_queues(struct tipc_link *l_ptr)
598596

599597
void tipc_link_reset(struct tipc_link *l)
600598
{
601-
struct tipc_node *owner = l->owner;
602-
603599
tipc_link_fsm_evt(l, LINK_RESET_EVT);
604600

605601
/* Link is down, accept any session */
@@ -611,14 +607,10 @@ void tipc_link_reset(struct tipc_link *l)
611607
/* Prepare for renewed mtu size negotiation */
612608
l->mtu = l->advertised_mtu;
613609

614-
/* Clean up all queues, except inputq: */
610+
/* Clean up all queues: */
615611
__skb_queue_purge(&l->transmq);
616612
__skb_queue_purge(&l->deferdq);
617-
if (!owner->inputq)
618-
owner->inputq = l->inputq;
619-
skb_queue_splice_init(&l->wakeupq, owner->inputq);
620-
if (!skb_queue_empty(owner->inputq))
621-
owner->action_flags |= TIPC_MSG_EVT;
613+
skb_queue_splice_init(&l->wakeupq, l->inputq);
622614

623615
tipc_link_purge_backlog(l);
624616
kfree_skb(l->reasm_buf);
@@ -972,25 +964,18 @@ static bool tipc_data_input(struct tipc_link *link, struct sk_buff *skb)
972964
{
973965
struct tipc_node *node = link->owner;
974966
struct tipc_msg *msg = buf_msg(skb);
975-
u32 dport = msg_destport(msg);
976967

977968
switch (msg_user(msg)) {
978969
case TIPC_LOW_IMPORTANCE:
979970
case TIPC_MEDIUM_IMPORTANCE:
980971
case TIPC_HIGH_IMPORTANCE:
981972
case TIPC_CRITICAL_IMPORTANCE:
982973
case CONN_MANAGER:
983-
if (tipc_skb_queue_tail(link->inputq, skb, dport)) {
984-
node->inputq = link->inputq;
985-
node->action_flags |= TIPC_MSG_EVT;
986-
}
974+
skb_queue_tail(link->inputq, skb);
987975
return true;
988976
case NAME_DISTRIBUTOR:
989977
node->bclink.recv_permitted = true;
990-
node->namedq = link->namedq;
991978
skb_queue_tail(link->namedq, skb);
992-
if (skb_queue_len(link->namedq) == 1)
993-
node->action_flags |= TIPC_NAMED_MSG_EVT;
994979
return true;
995980
case MSG_BUNDLER:
996981
case TUNNEL_PROTOCOL:

net/tipc/msg.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -862,28 +862,6 @@ static inline struct sk_buff *tipc_skb_dequeue(struct sk_buff_head *list,
862862
return skb;
863863
}
864864

865-
/* tipc_skb_queue_tail(): add buffer to tail of list;
866-
* @list: list to be appended to
867-
* @skb: buffer to append. Always appended
868-
* @dport: the destination port of the buffer
869-
* returns true if dport differs from previous destination
870-
*/
871-
static inline bool tipc_skb_queue_tail(struct sk_buff_head *list,
872-
struct sk_buff *skb, u32 dport)
873-
{
874-
struct sk_buff *_skb = NULL;
875-
bool rv = false;
876-
877-
spin_lock_bh(&list->lock);
878-
_skb = skb_peek_tail(list);
879-
if (!_skb || (msg_destport(buf_msg(_skb)) != dport) ||
880-
(skb_queue_len(list) > 32))
881-
rv = true;
882-
__skb_queue_tail(list, skb);
883-
spin_unlock_bh(&list->lock);
884-
return rv;
885-
}
886-
887865
/* tipc_skb_queue_sorted(); sort pkt into list according to sequence number
888866
* @list: list to be appended to
889867
* @skb: buffer to add

net/tipc/node.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -873,10 +873,8 @@ static void node_lost_contact(struct tipc_node *n_ptr,
873873
SHORT_H_SIZE, 0, tn->own_addr,
874874
conn->peer_node, conn->port,
875875
conn->peer_port, TIPC_ERR_NO_NODE);
876-
if (likely(skb)) {
876+
if (likely(skb))
877877
skb_queue_tail(inputq, skb);
878-
n_ptr->action_flags |= TIPC_MSG_EVT;
879-
}
880878
list_del(&conn->list);
881879
kfree(conn);
882880
}
@@ -923,27 +921,20 @@ void tipc_node_unlock(struct tipc_node *node)
923921
u32 flags = node->action_flags;
924922
u32 link_id = 0;
925923
struct list_head *publ_list;
926-
struct sk_buff_head *inputq = node->inputq;
927-
struct sk_buff_head *namedq;
928924

929-
if (likely(!flags || (flags == TIPC_MSG_EVT))) {
930-
node->action_flags = 0;
925+
if (likely(!flags)) {
931926
spin_unlock_bh(&node->lock);
932-
if (flags == TIPC_MSG_EVT)
933-
tipc_sk_rcv(net, inputq);
934927
return;
935928
}
936929

937930
addr = node->addr;
938931
link_id = node->link_id;
939-
namedq = node->namedq;
940932
publ_list = &node->publ_list;
941933

942-
node->action_flags &= ~(TIPC_MSG_EVT |
943-
TIPC_NOTIFY_NODE_DOWN | TIPC_NOTIFY_NODE_UP |
934+
node->action_flags &= ~(TIPC_NOTIFY_NODE_DOWN | TIPC_NOTIFY_NODE_UP |
944935
TIPC_NOTIFY_LINK_DOWN | TIPC_NOTIFY_LINK_UP |
945936
TIPC_WAKEUP_BCAST_USERS | TIPC_BCAST_MSG_EVT |
946-
TIPC_NAMED_MSG_EVT | TIPC_BCAST_RESET);
937+
TIPC_BCAST_RESET);
947938

948939
spin_unlock_bh(&node->lock);
949940

@@ -964,12 +955,6 @@ void tipc_node_unlock(struct tipc_node *node)
964955
tipc_nametbl_withdraw(net, TIPC_LINK_STATE, addr,
965956
link_id, addr);
966957

967-
if (flags & TIPC_MSG_EVT)
968-
tipc_sk_rcv(net, inputq);
969-
970-
if (flags & TIPC_NAMED_MSG_EVT)
971-
tipc_named_rcv(net, namedq);
972-
973958
if (flags & TIPC_BCAST_MSG_EVT)
974959
tipc_bclink_input(net);
975960

@@ -1270,6 +1255,9 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b)
12701255
if (unlikely(rc & TIPC_LINK_DOWN_EVT))
12711256
tipc_node_link_down(n, bearer_id, false);
12721257

1258+
if (unlikely(!skb_queue_empty(&n->bclink.namedq)))
1259+
tipc_named_rcv(net, &n->bclink.namedq);
1260+
12731261
if (!skb_queue_empty(&le->inputq))
12741262
tipc_sk_rcv(net, &le->inputq);
12751263

net/tipc/node.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@
5353
* TIPC_DISTRIBUTE_NAME: publish or withdraw link state name type
5454
*/
5555
enum {
56-
TIPC_MSG_EVT = 1,
5756
TIPC_NOTIFY_NODE_DOWN = (1 << 3),
5857
TIPC_NOTIFY_NODE_UP = (1 << 4),
5958
TIPC_WAKEUP_BCAST_USERS = (1 << 5),
6059
TIPC_NOTIFY_LINK_UP = (1 << 6),
6160
TIPC_NOTIFY_LINK_DOWN = (1 << 7),
62-
TIPC_NAMED_MSG_EVT = (1 << 8),
6361
TIPC_BCAST_MSG_EVT = (1 << 9),
6462
TIPC_BCAST_RESET = (1 << 10)
6563
};
@@ -124,8 +122,6 @@ struct tipc_node {
124122
spinlock_t lock;
125123
struct net *net;
126124
struct hlist_node hash;
127-
struct sk_buff_head *inputq;
128-
struct sk_buff_head *namedq;
129125
int active_links[2];
130126
struct tipc_link_entry links[MAX_BEARERS];
131127
int action_flags;

0 commit comments

Comments
 (0)