All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: Stephen Hemminger <shemminger@osdl.org>
Cc: netdev@vger.kernel.org
Subject: [IPROUTE2] Add rule notification support to ip monitor
Date: Fri, 10 Nov 2006 12:27:10 +0100	[thread overview]
Message-ID: <20061110112710.GG8693@postel.suug.ch> (raw)

Index: iproute2.git/ip/ip_common.h
===================================================================
--- iproute2.git.orig/ip/ip_common.h	2006-11-10 12:22:46.000000000 +0100
+++ iproute2.git/ip/ip_common.h	2006-11-10 12:23:06.000000000 +0100
@@ -20,6 +20,8 @@
 		       struct nlmsghdr *n, void *arg);
 extern int print_prefix(const struct sockaddr_nl *who,
 			struct nlmsghdr *n, void *arg);
+extern int print_rule(const struct sockaddr_nl *who,
+		      struct nlmsghdr *n, void *arg);
 extern int do_ipaddr(int argc, char **argv);
 extern int do_iproute(int argc, char **argv);
 extern int do_iprule(int argc, char **argv);
Index: iproute2.git/ip/ipmonitor.c
===================================================================
--- iproute2.git.orig/ip/ipmonitor.c	2006-11-10 12:21:00.000000000 +0100
+++ iproute2.git/ip/ipmonitor.c	2006-11-10 12:23:47.000000000 +0100
@@ -62,6 +62,10 @@
 		print_prefix(who, n, arg);
 		return 0;
 	}
+	if (n->nlmsg_type == RTM_NEWRULE || n->nlmsg_type == RTM_DELRULE) {
+		print_rule(who, n, arg);
+		return 0;
+	}
 	if (n->nlmsg_type == 15) {
 		char *tstr;
 		time_t secs = ((__u32*)NLMSG_DATA(n))[0];
Index: iproute2.git/ip/iprule.c
===================================================================
--- iproute2.git.orig/ip/iprule.c	2006-11-10 12:21:55.000000000 +0100
+++ iproute2.git/ip/iprule.c	2006-11-10 12:24:46.000000000 +0100
@@ -46,8 +46,7 @@
 	exit(-1);
 }
 
-static int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n,
-		      void *arg)
+int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 {
 	FILE *fp = (FILE*)arg;
 	struct rtmsg *r = NLMSG_DATA(n);
@@ -58,7 +57,7 @@
 	char abuf[256];
 	SPRINT_BUF(b1);
 
-	if (n->nlmsg_type != RTM_NEWRULE)
+	if (n->nlmsg_type != RTM_NEWRULE && n->nlmsg_type != RTM_DELRULE)
 		return 0;
 
 	len -= NLMSG_LENGTH(sizeof(*r));
@@ -76,6 +75,9 @@
 	else if (r->rtm_family == AF_IPX)
 		host_len = 80;
 
+	if (n->nlmsg_type == RTM_DELRULE)
+		fprintf(fp, "Deleted ");
+
 	if (tb[RTA_PRIORITY])
 		fprintf(fp, "%u:\t", *(unsigned*)RTA_DATA(tb[RTA_PRIORITY]));
 	else

             reply	other threads:[~2006-11-10 11:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-10 11:27 Thomas Graf [this message]
2006-11-10 17:41 ` [IPROUTE2] Add rule notification support to ip monitor Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061110112710.GG8693@postel.suug.ch \
    --to=tgraf@suug.ch \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.