Skip to contentSkip to conversation

packet : remove init_net restriction

PATCH Applied Daniel Lezcano 2 participants 4 messages Apr 15, 2010 – Apr 16, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 packet : remove init_net restriction

The af_packet protocol is used by Perl to do ioctls as reported by Stephane Riviere:

"Net::RawIP relies on SIOCGIFADDR et SIOCGIFHWADDR to get the IP and MAC addresses of the network interface."

But in a new network namespace these ioctl fail because it is disabled for a namespace different from the init_net_ns.

These two lines should not be there as af_inet and af_packet are namespace aware since a long time now. I suppose we forget to remove these lines because we sent the af_packet first, before af_inet was supported.

---
 net/packet/af_packet.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
net/packet/af_packet.c +0 -2
index cc90363..243946d 100644
@@ -2169,8 +2169,6 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
 	case SIOCGIFDSTADDR:
 	case SIOCSIFDSTADDR:
 	case SIOCSIFFLAGS:
-		if (!net_eq(sock_net(sk), &init_net))
-			return -ENOIOCTLCMD;
 		return inet_dgram_ops.ioctl(sock, cmd, arg);
 #endif
 
Signature · 1 line
1.6.3.3
#1 lore raw
Quoted 25 lines · Daniel Lezcano

The af_packet protocol is used by Perl to do ioctls as reported by Stephane Riviere:

"Net::RawIP relies on SIOCGIFADDR et SIOCGIFHWADDR to get the IP and MAC addresses of the network interface."

But in a new network namespace these ioctl fail because it is disabled for a namespace different from the init_net_ns.

These two lines should not be there as af_inet and af_packet are namespace aware since a long time now. I suppose we forget to remove these lines because we sent the af_packet first, before af_inet was supported.

---
 net/packet/af_packet.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
net/packet/af_packet.c +0 -0
index cc90363..243946d 100644

net/packet/af_packet.c static int packet_ioctl(struct socket *sock, unsigned int cmd, · line 2174

Quoted 8 lines
net/packet/af_packet.c +0 -2
@@ -2169,8 +2169,6 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
 	case SIOCGIFDSTADDR:
 	case SIOCSIFDSTADDR:
 	case SIOCSIFFLAGS:
-		if (!net_eq(sock_net(sk), &init_net))
-			return -ENOIOCTLCMD;
 		return inet_dgram_ops.ioctl(sock, cmd, arg);
 #endif
 

Shall I send it against net-next-2.6 ?

Thanks
-- Daniel

maintainer
#2 lore raw

From: Daniel Lezcano <[email protected]>
Date: Fri, 16 Apr 2010 17:04:28 +0200

Quoted 1 line

Shall I send it against net-next-2.6 ?

No, I'll likely add it to net-2.6, I just haven't gotten around to it yet.

Thanks.

maintainer Applied
#3 lore raw
In reply to Daniel Lezcano

From: Daniel Lezcano <[email protected]>
Date: Thu, 15 Apr 2010 11:11:14 +0200

Quoted 9 lines

The af_packet protocol is used by Perl to do ioctls as reported by Stephane Riviere:

"Net::RawIP relies on SIOCGIFADDR et SIOCGIFHWADDR to get the IP and MAC addresses of the network interface."

But in a new network namespace these ioctl fail because it is disabled for a namespace different from the init_net_ns.

Quoted 6 lines

These two lines should not be there as af_inet and af_packet are namespace aware since a long time now. I suppose we forget to remove these lines because we sent the af_packet first, before af_inet was supported.

Applied, thanks!