netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 1/2] tc filters: display handle in events when a filter is deleted
@ 2016-10-17  9:34 Jamal Hadi Salim
  2016-10-17  9:34 ` [PATCH iproute2 2/2] tc filters: fix filters to display handle when deleted even when no option Jamal Hadi Salim
  0 siblings, 1 reply; 3+ messages in thread
From: Jamal Hadi Salim @ 2016-10-17  9:34 UTC (permalink / raw)
  To: stephen; +Cc: netdev, daniel, xiyou.wangcong, mrv, Jamal Hadi Salim

From: Jamal Hadi Salim <jhs@mojatatu.com>

An event being displayed via "tc mon" should display the filter handle.
The filter handle is a required parameter when deleting a filter and
therefore the delete event should mimic/mirror the command sent.
A simple test, run tc monitor on one window, on another try adding
a filter:
..
sudo $TC filter add dev $ETH parent ffff: protocol ip pref 1 \
u32 match ip protocol 1 0xff \
flowid 1:1 \
action ok
..

.. get its handle by dumping ...
sudo $TC -s filter ls dev $ETH parent ffff: protocol ip
... find out the handle (say it was 800::800)
... go delete it..
sudo $TC filter del dev $ETH handle 800::800 parent ffff: \
protocol ip prio 1 u32

now see tc monitor reporting it without handle. After this patch
with a handle.

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
 tc/tc_filter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tc/tc_filter.c b/tc/tc_filter.c
index 2413cef..4efc44f 100644
--- a/tc/tc_filter.c
+++ b/tc/tc_filter.c
@@ -253,12 +253,13 @@ int print_filter(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 	}
 	fprintf(fp, "%s ", rta_getattr_str(tb[TCA_KIND]));
 	q = get_filter_kind(RTA_DATA(tb[TCA_KIND]));
-	if (tb[TCA_OPTIONS]) {
+	if (tb[TCA_OPTIONS] || n->nlmsg_type == RTM_DELTFILTER) {
 		if (q)
 			q->print_fopt(q, fp, tb[TCA_OPTIONS], t->tcm_handle);
 		else
 			fprintf(fp, "[cannot parse parameters]");
 	}
+
 	fprintf(fp, "\n");
 
 	if (show_stats && (tb[TCA_STATS] || tb[TCA_STATS2])) {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-26 17:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-17  9:34 [PATCH iproute2 1/2] tc filters: display handle in events when a filter is deleted Jamal Hadi Salim
2016-10-17  9:34 ` [PATCH iproute2 2/2] tc filters: fix filters to display handle when deleted even when no option Jamal Hadi Salim
2016-10-26 17:57   ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).