tipc: add loopback device tracking
Subsystems (3)
PATCH v2 1/1 tipc: add loopback device tracking
Since node internal messages are passed directly to socket it is not possible to observe this message exchange via tcpdump or wireshark.
We now remedy this by making it possible to clone such messages and send the clones to the loopback interface. The clones are dropped at reception and have no functional role except making the traffic visible.
The feature is turned on/off by enabling/disabling the loopback "bearer" "eth:lo".
--- net/tipc/bcast.c | 4 +++- net/tipc/bearer.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ net/tipc/bearer.h | 3 +++ net/tipc/core.c | 5 ++++- net/tipc/core.h | 12 ++++++++++ net/tipc/node.c | 1 + net/tipc/topsrv.c | 2 ++ 7 files changed, 92 insertions(+), 2 deletions(-)
net/tipc/bcast.c +3 -1
@@ -406,8 +406,10 @@ int tipc_mcast_xmit(struct net *net, struct sk_buff_head *pkts, rc =tipc_bcast_xmit (net, pkts, cong_link_cnt); } -if (dests->local) +if (dests->local) { +tipc_loopback_trace (net, &localq);tipc_sk_mcast_rcv (net, &localq, &inputq); + } exit:/* This queue should normally be empty by now */ __skb_queue_purge (pkts);
net/tipc/bearer.c +67 -0
85 lines not on this page · raw message
net/tipc/bearer.h +3 -0
@@ -232,6 +232,9 @@ void tipc_bearer_xmit(struct net *net, u32 bearer_id, struct tipc_media_addr *dst);void tipc_bearer_bc_xmit (struct net *net,u32 bearer_id,struct sk_buff_head *xmitq); +void tipc_clone_to_loopback (struct net *net,struct sk_buff_head *xmitq); +int tipc_attach_loopback (struct net *net); +void tipc_detach_loopback (struct net *net);/* check if device MTU is too low for tipc headers */ static inline bool tipc_mtu_bad (struct net_device *dev,unsigned int reserve)
net/tipc/core.c +4 -1
@@ -81,7 +81,9 @@ static int __net_init tipc_init_net(struct net *net) err =tipc_bcast_init (net);if (err) goto out_bclink; - + err =tipc_attach_loopback (net); +if (err) + goto out_bclink;return 0 ; out_bclink:
@@ -94,6 +96,7 @@ static int __net_init tipc_init_net(struct net *net) static void __net_exit tipc_exit_net(struct net *net) { +tipc_detach_loopback (net);tipc_net_stop (net);tipc_bcast_stop (net);tipc_nametbl_stop (net);
net/tipc/core.h +12 -0
@@ -67,6 +67,7 @@ struct tipc_link;struct tipc_name_table ;struct tipc_topsrv ;struct tipc_monitor ; +void tipc_clone_to_loopback (struct net *net,struct sk_buff_head *pkts);#define TIPC_MOD_VER "2.0.0"
@@ -125,6 +126,10 @@ struct tipc_net {/* Cluster capabilities */ u16 capabilities; + +/* Tracing of node internal messages */ +struct packet_type loopback_pt; +bool loopback_trace; };static inline struct tipc_net *tipc_net (struct net *net)
@@ -152,6 +157,13 @@ static inline struct tipc_topsrv *tipc_topsrv(struct net *net)return tipc_net (net)->topsrv; } +static inline void tipc_loopback_trace (struct net *net, +struct sk_buff_head *pkts) +{ +if (unlikely (tipc_net (net)->loopback_trace)) +tipc_clone_to_loopback (net, pkts); +} +static inline unsigned int tipc_hashfn (u32 addr) {return addr & (NODE_HTABLE_SIZE -1 );
net/tipc/node.c +1 -0
@@ -1439,6 +1439,7 @@ int tipc_node_xmit(struct net *net, struct sk_buff_head *list,int rc;if (in_own_node (net, dnode)) { +tipc_loopback_trace (net, list);tipc_sk_rcv (net, list);return 0 ; }
net/tipc/topsrv.c +2 -0
@@ -40,6 +40,7 @@#include "socket.h" #include "addr.h" #include "msg.h" +#include "bearer.h" #include <net/sock.h> #include <linux/module.h>
@@ -608,6 +609,7 @@ static void tipc_topsrv_kern_evt(struct net *net, struct tipc_event *evt)memcpy (msg_data (buf_msg (skb)), evt,sizeof (*evt));skb_queue_head_init (&evtq);__skb_queue_tail (&evtq, skb); +tipc_loopback_trace (net, &evtq);tipc_sk_rcv (net, &evtq); }
Signature · 1 line
2.11.0
David Miller
maintainerFrom: [email protected]
Date: Mon, 24 Jun 2019 16:44:35 +1000
Quoted 7 lines
Since node internal messages are passed directly to socket it is not possible to observe this message exchange via tcpdump or wireshark.
We now remedy this by making it possible to clone such messages and send the clones to the loopback interface. The clones are dropped at reception and have no functional role except making the traffic visible.
Quoted 5 lines
The feature is turned on/off by enabling/disabling the loopback "bearer" "eth:lo".
Acked-by Jon Maloy <[email protected]>Signed-off-by John Rutherford <[email protected]>
What a waste, just clone the packet, attach loopback to it, and go:
if (dev_nit_active(loopback_dev)) dev_queue_xmit_nit(skb, loopback_dev);
Quoted 23 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of David Miller
Sent: 24-Jun-19 10:29
To: John Rutherford <[email protected]>
Cc: [email protected]
Subject: Re: [net-next v2] tipc: add loopback device trackingFrom: [email protected]
Date: Mon, 24 Jun 2019 16:44:35 +1000Quoted 10 lines
Since node internal messages are passed directly to socket it is not possible to observe this message exchange via tcpdump or wireshark.
We now remedy this by making it possible to clone such messages and send the clones to the loopback interface. The clones are dropped at reception and have no functional role except making the traffic visible.
The feature is turned on/off by enabling/disabling the loopback "bearer" "eth:lo".
Quoted 7 lines
Quoted 2 lines
Acked-by Jon Maloy <[email protected]>Signed-off-by John Rutherford <[email protected]>What a waste, just clone the packet, attach loopback to it, and go:
if (dev_nit_active(loopback_dev)) dev_queue_xmit_nit(skb, loopback_dev);
I was never quite happy with this patch, so thank you for the feedback!
///jon