netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PATCH: ioctl send PID in netlink events
@ 2005-06-02 13:52 jamal
  2005-06-03  1:00 ` Thomas Graf
  0 siblings, 1 reply; 5+ messages in thread
From: jamal @ 2005-06-02 13:52 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 536 bytes --]


This is where i was trying to get to ;->
This patch is on top of the earlier one i sent for explicit types.
I still have to think about how to best do IPV6 routes as well as ARP
and NDISC. If anyone has suggestions or wants to tackle them let me
know, the v6 route is not going to be a pretty one i think.

cheers,
jamal


This patch ensures that netlink events created as a result of programns
using ioctls (such as ifconfig, route etc) contains the correct PID of
those events.
 
Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca> 



[-- Attachment #2: ifconf_pid_p --]
[-- Type: text/plain, Size: 3399 bytes --]

net/core/rtnetlink.c: needs update
net/ipv4/devinet.c: needs update
net/ipv4/fib_semantics.c: needs update
net/ipv6/addrconf.c: needs update
Index: net/core/rtnetlink.c
===================================================================
--- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/core/rtnetlink.c  (mode:100644)
+++ uncommitted/net/core/rtnetlink.c  (mode:100644)
@@ -452,7 +452,7 @@
 	if (!skb)
 		return;
 
-	if (rtnetlink_fill_ifinfo(skb, dev, type, 0, 0, change, 0) < 0) {
+	if (rtnetlink_fill_ifinfo(skb, dev, type, current->pid, 0, change, 0) < 0) {
 		kfree_skb(skb);
 		return;
 	}
Index: net/ipv4/devinet.c
===================================================================
--- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv4/devinet.c  (mode:100644)
+++ uncommitted/net/ipv4/devinet.c  (mode:100644)
@@ -236,6 +236,7 @@
 	struct in_ifaddr *promote = NULL;
 	struct in_ifaddr *ifa1 = *ifap;
 
+	printk("inet_del_ifa: pid %d\n",current->pid);
 	ASSERT_RTNL();
 
 	/* 1. Deleting primary ifaddr forces deletion all secondaries 
@@ -305,6 +306,7 @@
 
 	ASSERT_RTNL();
 
+	printk("inet_insert_ifa: pid %d\n",current->pid);
 	if (!ifa->ifa_local) {
 		inet_free_ifa(ifa);
 		return 0;
@@ -1112,7 +1114,7 @@
 
 	if (!skb)
 		netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, ENOBUFS);
-	else if (inet_fill_ifaddr(skb, ifa, 0, 0, event, 0) < 0) {
+	else if (inet_fill_ifaddr(skb, ifa, current->pid, 0, event, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, EINVAL);
 	} else {
Index: net/ipv4/fib_semantics.c
===================================================================
--- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv4/fib_semantics.c  (mode:100644)
+++ uncommitted/net/ipv4/fib_semantics.c  (mode:100644)
@@ -276,7 +276,7 @@
 	       struct nlmsghdr *n, struct netlink_skb_parms *req)
 {
 	struct sk_buff *skb;
-	u32 pid = req ? req->pid : 0;
+	u32 pid = req ? req->pid : n->nlmsg_pid;
 	int size = NLMSG_SPACE(sizeof(struct rtmsg)+256);
 
 	skb = alloc_skb(size, GFP_KERNEL);
@@ -1035,7 +1035,7 @@
 	}
 
 	nl->nlmsg_flags = NLM_F_REQUEST;
-	nl->nlmsg_pid = 0;
+	nl->nlmsg_pid = current->pid;
 	nl->nlmsg_seq = 0;
 	nl->nlmsg_len = NLMSG_LENGTH(sizeof(*rtm));
 	if (cmd == SIOCDELRT) {
Index: net/ipv6/addrconf.c
===================================================================
--- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv6/addrconf.c  (mode:100644)
+++ uncommitted/net/ipv6/addrconf.c  (mode:100644)
@@ -2872,7 +2872,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFADDR, ENOBUFS);
 		return;
 	}
-	if (inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0) < 0) {
+	if (inet6_fill_ifaddr(skb, ifa, current->pid, 0, event, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFADDR, EINVAL);
 		return;
@@ -3007,7 +3007,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFINFO, ENOBUFS);
 		return;
 	}
-	if (inet6_fill_ifinfo(skb, idev, 0, 0, event, 0) < 0) {
+	if (inet6_fill_ifinfo(skb, idev, current->pid, 0, event, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFINFO, EINVAL);
 		return;
@@ -3064,7 +3064,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_PREFIX, ENOBUFS);
 		return;
 	}
-	if (inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0) < 0) {
+	if (inet6_fill_prefix(skb, idev, pinfo, current->pid, 0, event, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_PREFIX, EINVAL);
 		return;

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

* Re: PATCH: ioctl send PID in netlink events
  2005-06-02 13:52 PATCH: ioctl send PID in netlink events jamal
@ 2005-06-03  1:00 ` Thomas Graf
  2005-06-03  1:37   ` jamal
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Graf @ 2005-06-03  1:00 UTC (permalink / raw)
  To: jamal; +Cc: David S. Miller, netdev

> Index: net/ipv4/devinet.c
> ===================================================================
> --- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv4/devinet.c  (mode:100644)
> +++ uncommitted/net/ipv4/devinet.c  (mode:100644)
> @@ -236,6 +236,7 @@
>  	struct in_ifaddr *promote = NULL;
>  	struct in_ifaddr *ifa1 = *ifap;
>  
> +	printk("inet_del_ifa: pid %d\n",current->pid);
>  	ASSERT_RTNL();
>  
>  	/* 1. Deleting primary ifaddr forces deletion all secondaries 
> @@ -305,6 +306,7 @@
>  
>  	ASSERT_RTNL();
>  
> +	printk("inet_insert_ifa: pid %d\n",current->pid);
>  	if (!ifa->ifa_local) {
>  		inet_free_ifa(ifa);
>  		return 0;

Don't you want to remove these?


> Index: net/ipv4/fib_semantics.c
> ===================================================================
> --- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv4/fib_semantics.c  (mode:100644)
> +++ uncommitted/net/ipv4/fib_semantics.c  (mode:100644)
> @@ -276,7 +276,7 @@
>  	       struct nlmsghdr *n, struct netlink_skb_parms *req)
>  {
>  	struct sk_buff *skb;
> -	u32 pid = req ? req->pid : 0;
> +	u32 pid = req ? req->pid : n->nlmsg_pid;
>  	int size = NLMSG_SPACE(sizeof(struct rtmsg)+256);
>  
>  	skb = alloc_skb(size, GFP_KERNEL);
> @@ -1035,7 +1035,7 @@
>  	}
>  
>  	nl->nlmsg_flags = NLM_F_REQUEST;
> -	nl->nlmsg_pid = 0;
> +	nl->nlmsg_pid = current->pid;
>  	nl->nlmsg_seq = 0;
>  	nl->nlmsg_len = NLMSG_LENGTH(sizeof(*rtm));
>  	if (cmd == SIOCDELRT) {

Neat ;->

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

* Re: PATCH: ioctl send PID in netlink events
  2005-06-03  1:00 ` Thomas Graf
@ 2005-06-03  1:37   ` jamal
  2005-06-03  3:32     ` jamal
  0 siblings, 1 reply; 5+ messages in thread
From: jamal @ 2005-06-03  1:37 UTC (permalink / raw)
  To: Thomas Graf; +Cc: David S. Miller, netdev

On Fri, 2005-03-06 at 03:00 +0200, Thomas Graf wrote:
> > Index: net/ipv4/devinet.c
> > ===================================================================
> > --- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv4/devinet.c  (mode:100644)
> > +++ uncommitted/net/ipv4/devinet.c  (mode:100644)
> > @@ -236,6 +236,7 @@
> >  	struct in_ifaddr *promote = NULL;
> >  	struct in_ifaddr *ifa1 = *ifap;
> >  
> > +	printk("inet_del_ifa: pid %d\n",current->pid);
> >  	ASSERT_RTNL();
> >  
> >  	/* 1. Deleting primary ifaddr forces deletion all secondaries 
> > @@ -305,6 +306,7 @@
> >  
> >  	ASSERT_RTNL();
> >  
> > +	printk("inet_insert_ifa: pid %d\n",current->pid);
> >  	if (!ifa->ifa_local) {
> >  		inet_free_ifa(ifa);
> >  		return 0;
> 
> Don't you want to remove these?
> 
> 

Yes, how did those get there? ;-> 

> > Index: net/ipv4/fib_semantics.c
> > ===================================================================
> > --- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv4/fib_semantics.c  (mode:100644)
> > +++ uncommitted/net/ipv4/fib_semantics.c  (mode:100644)
> > @@ -276,7 +276,7 @@
> >  	       struct nlmsghdr *n, struct netlink_skb_parms *req)
> >  {
> >  	struct sk_buff *skb;
> > -	u32 pid = req ? req->pid : 0;
> > +	u32 pid = req ? req->pid : n->nlmsg_pid;
> >  	int size = NLMSG_SPACE(sizeof(struct rtmsg)+256);
> >  
> >  	skb = alloc_skb(size, GFP_KERNEL);
> > @@ -1035,7 +1035,7 @@
> >  	}
> >  
> >  	nl->nlmsg_flags = NLM_F_REQUEST;
> > -	nl->nlmsg_pid = 0;
> > +	nl->nlmsg_pid = current->pid;
> >  	nl->nlmsg_seq = 0;
> >  	nl->nlmsg_len = NLMSG_LENGTH(sizeof(*rtm));
> >  	if (cmd == SIOCDELRT) {
> 
> Neat ;->


The second one could probably use the new macros.
Maybe i will wait until Dave puts this in his tree and send a small
change; else you could send it.

cheers,
jamal

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

* Re: PATCH: ioctl send PID in netlink events
  2005-06-03  1:37   ` jamal
@ 2005-06-03  3:32     ` jamal
  2005-06-03  5:09       ` David S. Miller
  0 siblings, 1 reply; 5+ messages in thread
From: jamal @ 2005-06-03  3:32 UTC (permalink / raw)
  To: Thomas Graf; +Cc: David S. Miller, netdev

[-- Attachment #1: Type: text/plain, Size: 367 bytes --]

Dave,

If you havent applied that patch to net-2.6.13 heres one that removes
those extrenous printks.

On Thu, 2005-02-06 at 21:37 -0400, jamal wrote:

> The second one could probably use the new macros.
> Maybe i will wait until Dave puts this in his tree and send a small
> change; else you could send it.
> 

Actually cant be done, sorry i lied ;->

cheers,
jamal

[-- Attachment #2: ifconf-2 --]
[-- Type: text/plain, Size: 3020 bytes --]

net/core/rtnetlink.c: needs update
net/ipv4/devinet.c: needs update
net/ipv4/fib_semantics.c: needs update
net/ipv6/addrconf.c: needs update
Index: net/core/rtnetlink.c
===================================================================
--- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/core/rtnetlink.c  (mode:100644)
+++ uncommitted/net/core/rtnetlink.c  (mode:100644)
@@ -452,7 +452,7 @@
 	if (!skb)
 		return;
 
-	if (rtnetlink_fill_ifinfo(skb, dev, type, 0, 0, change, 0) < 0) {
+	if (rtnetlink_fill_ifinfo(skb, dev, type, current->pid, 0, change, 0) < 0) {
 		kfree_skb(skb);
 		return;
 	}
Index: net/ipv4/devinet.c
===================================================================
--- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv4/devinet.c  (mode:100644)
+++ uncommitted/net/ipv4/devinet.c  (mode:100644)
@@ -1112,7 +1112,7 @@
 
 	if (!skb)
 		netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, ENOBUFS);
-	else if (inet_fill_ifaddr(skb, ifa, 0, 0, event, 0) < 0) {
+	else if (inet_fill_ifaddr(skb, ifa, current->pid, 0, event, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, EINVAL);
 	} else {
Index: net/ipv4/fib_semantics.c
===================================================================
--- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv4/fib_semantics.c  (mode:100644)
+++ uncommitted/net/ipv4/fib_semantics.c  (mode:100644)
@@ -276,7 +276,7 @@
 	       struct nlmsghdr *n, struct netlink_skb_parms *req)
 {
 	struct sk_buff *skb;
-	u32 pid = req ? req->pid : 0;
+	u32 pid = req ? req->pid : n->nlmsg_pid;
 	int size = NLMSG_SPACE(sizeof(struct rtmsg)+256);
 
 	skb = alloc_skb(size, GFP_KERNEL);
@@ -1035,7 +1035,7 @@
 	}
 
 	nl->nlmsg_flags = NLM_F_REQUEST;
-	nl->nlmsg_pid = 0;
+	nl->nlmsg_pid = current->pid;
 	nl->nlmsg_seq = 0;
 	nl->nlmsg_len = NLMSG_LENGTH(sizeof(*rtm));
 	if (cmd == SIOCDELRT) {
Index: net/ipv6/addrconf.c
===================================================================
--- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv6/addrconf.c  (mode:100644)
+++ uncommitted/net/ipv6/addrconf.c  (mode:100644)
@@ -2872,7 +2872,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFADDR, ENOBUFS);
 		return;
 	}
-	if (inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0) < 0) {
+	if (inet6_fill_ifaddr(skb, ifa, current->pid, 0, event, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFADDR, EINVAL);
 		return;
@@ -3007,7 +3007,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFINFO, ENOBUFS);
 		return;
 	}
-	if (inet6_fill_ifinfo(skb, idev, 0, 0, event, 0) < 0) {
+	if (inet6_fill_ifinfo(skb, idev, current->pid, 0, event, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFINFO, EINVAL);
 		return;
@@ -3064,7 +3064,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_PREFIX, ENOBUFS);
 		return;
 	}
-	if (inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0) < 0) {
+	if (inet6_fill_prefix(skb, idev, pinfo, current->pid, 0, event, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_PREFIX, EINVAL);
 		return;

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

* Re: PATCH: ioctl send PID in netlink events
  2005-06-03  3:32     ` jamal
@ 2005-06-03  5:09       ` David S. Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David S. Miller @ 2005-06-03  5:09 UTC (permalink / raw)
  To: hadi; +Cc: tgraf, netdev

From: jamal <hadi@cyberus.ca>
Date: Thu, 02 Jun 2005 23:32:55 -0400

> If you havent applied that patch to net-2.6.13 heres one that removes
> those extrenous printks.

Applied, thanks Jamal.

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

end of thread, other threads:[~2005-06-03  5:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-02 13:52 PATCH: ioctl send PID in netlink events jamal
2005-06-03  1:00 ` Thomas Graf
2005-06-03  1:37   ` jamal
2005-06-03  3:32     ` jamal
2005-06-03  5:09       ` David S. Miller

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).