Skip to contentSkip to conversation

net,man - IP_NODEFRAG option for IPv4 socket

PATCH Applied Jiri Olsa 7 participants 10 messages Jun 15, 2010 – Sep 11, 2010 3 messages not in the archive

Subsystems (5)
lore
Share & tools
lore

Jiri Olsa

author
#0 lore raw

cover net,man - IP_NODEFRAG option for IPv4 socket

hi,

this series contains patch for IP_NODEFRAG option for RAW sockets, and changes for man pages.

I'm sending this together, hope it's ok.

1/2 - net - IP_NODEFRAG option for IPv4 socket
2/2 - man - IP_NODEFRAG option for IPv4 socket

wbr,
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1276600052-16499-1-git-send-email-jolsa-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

author
#2 lore raw

PATCH 1/2 net - IP_NODEFRAG option for IPv4 socket

hi,

this patch is implementing IP_NODEFRAG option for IPv4 socket. The reason is, there's no other way to send out the packet with user customized header of the reassembly part.

wbr,
jirka

---
 include/linux/in.h                  |    1 +
 include/net/inet_sock.h             |    3 ++-
 net/ipv4/af_inet.c                  |    2 ++
 net/ipv4/ip_sockglue.c              |    9 ++++++++-
 net/ipv4/netfilter/nf_defrag_ipv4.c |    5 +++++
 5 files changed, 18 insertions(+), 2 deletions(-)
include/linux/in.h +1 -0
index 583c76f..41d88a4 100644
@@ -85,6 +85,7 @@ struct in_addr {
 #define IP_RECVORIGDSTADDR   IP_ORIGDSTADDR
 
 #define IP_MINTTL       21
+#define IP_NODEFRAG     22
 
 /* IP_MTU_DISCOVER values */
 #define IP_PMTUDISC_DONT		0	/* Never send DF frames */
include/net/inet_sock.h +2 -1
index 1653de5..1989cfd 100644
@@ -137,7 +137,8 @@ struct inet_sock {
 				hdrincl:1,
 				mc_loop:1,
 				transparent:1,
-				mc_all:1;
+				mc_all:1,
+				nodefrag:1;
 	int			mc_index;
 	__be32			mc_addr;
 	struct ip_mc_socklist	*mc_list;
net/ipv4/af_inet.c +2 -0
index 551ce56..84d2c8e 100644
@@ -355,6 +355,8 @@ lookup_protocol:
 	inet = inet_sk(sk);
 	inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0;
 
+	inet->nodefrag = 0;
+
 	if (SOCK_RAW == sock->type) {
 		inet->inet_num = protocol;
 		if (IPPROTO_RAW == protocol)
net/ipv4/ip_sockglue.c +8 -1
index ce23178..d8196e1 100644
@@ -449,7 +449,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
 			     (1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) |
 			     (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) |
 			     (1<<IP_PASSSEC) | (1<<IP_TRANSPARENT) |
-			     (1<<IP_MINTTL))) ||
+			     (1<<IP_MINTTL) | (1<<IP_NODEFRAG))) ||
 	    optname == IP_MULTICAST_TTL ||
 	    optname == IP_MULTICAST_ALL ||
 	    optname == IP_MULTICAST_LOOP ||
@@ -572,6 +572,13 @@ static int do_ip_setsockopt(struct sock *sk, int level,
 		}
 		inet->hdrincl = val ? 1 : 0;
 		break;
+	case IP_NODEFRAG:
+		if (sk->sk_type != SOCK_RAW) {
+			err = -ENOPROTOOPT;
+			break;
+		}
+		inet->nodefrag = val ? 1 : 0;
+		break;
 	case IP_MTU_DISCOVER:
 		if (val < IP_PMTUDISC_DONT || val > IP_PMTUDISC_PROBE)
 			goto e_inval;
net/ipv4/netfilter/nf_defrag_ipv4.c +5 -0
index cb763ae..eab8de3 100644
@@ -66,6 +66,11 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
 					  const struct net_device *out,
 					  int (*okfn)(struct sk_buff *))
 {
+	struct inet_sock *inet = inet_sk(skb->sk);
+
+	if (inet && inet->nodefrag)
+		return NF_ACCEPT;
+
 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
 #if !defined(CONFIG_NF_NAT) && !defined(CONFIG_NF_NAT_MODULE)
 	/* Previously seen (loopback)?  Ignore.  Do this before

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Applied
#3 lore raw

Re: [PATCH 1/2] net - IP_NODEFRAG option for IPv4 socket

From: Jiri Olsa <[email protected]>
Date: Tue, 15 Jun 2010 13:07:31 +0200

Quoted 5 lines

this patch is implementing IP_NODEFRAG option for IPv4 socket. The reason is, there's no other way to send out the packet with user customized header of the reassembly part.

Applied to net-next-2.6, thanks!

#4 lore raw

PATCH 2/2 man - IP_NODEFRAG option for IPv4 socket

In reply to Jiri Olsa

hi,

this patch adds description for IP_NODEFRAG option for IPv4 socket.

wbr,
jirka

---
 man7/ip.7 |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
man7/ip.7 +6 -0
index 34f7e80..12c0d5b 100644
@@ -705,6 +705,12 @@ socket option (see
 .BR IP_TTL " (since Linux 1.0)"
 Set or retrieve the current time-to-live field that is used in every packet
 sent from this socket.
+.TP
+.BR IP_NODEFRAG " (since Linux 2.6)"
+If enabled, the reassembly of outgoing packets is disabled in the netfilter layer.
+Only valid for
+.B SOCK_RAW
+sockets.
 .\" FIXME Document IP_XFRM_POLICY
 .\" Since Linux 2.5.48
 .\" Needs CAP_NET_ADMIN
#5 lore raw

Re: [PATCH 2/2] man - IP_NODEFRAG option for IPv4 socket

Hi Jiri,

Thanks for this patch. See below.

Quoted 18 lines · Jiri Olsa

hi,

this patch adds description for IP_NODEFRAG option for IPv4 socket.

wbr,
jirka

---
 man7/ip.7 |    6 ++++++

 1 files changed, 6 insertions(+), 0 deletions(-)
man7/ip.7 +0 -0
index 34f7e80..12c0d5b 100644
@@ -705,6 +705,12 @@ socket option (see
Quoted 5 lines

 .BR IP_TTL " (since Linux 1.0)"
 Set or retrieve the current time-to-live field that is used in every packet sent from this socket.
+.TP
+.BR IP_NODEFRAG " (since Linux 2.6)"

here, we'd write the exact version in which the flag is added. It looks like that might be 2.36, right?

Otherwise, this patch looks fine.

Cheers,

Michael

Quoted 12 lines
man7/ip.7 +4 -0
+If enabled, the reassembly of outgoing packets is disabled in the netfilter layer.
+Only valid for
+.B SOCK_RAW
+sockets.

 .\" FIXME Document IP_XFRM_POLICY
 .\" Since Linux 2.5.48
 .\" Needs CAP_NET_ADMIN
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface" http://blog.man7.org/
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): AANLkTim4N5rc8Sn_uo5bXsb9vjvKd3GTQD3p-1uApbB8-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#7 lore raw

Re: [PATCH 2/2] man - IP_NODEFRAG option for IPv4 socket

From: Michael Kerrisk <[email protected]>
Date: Sat, 26 Jun 2010 15:01:03 +0200

Quoted 6 lines
Quoted 3 lines

 sent from this socket.
+.TP
+.BR IP_NODEFRAG " (since Linux 2.6)"

here, we'd write the exact version in which the flag is added. It looks like that might be 2.36, right?

It'll show up in 2.6.36

I doubt I'll be alive when we make it to 2.36 :-)
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

PATCH v2 2/2 man - IP_NODEFRAG option for IPv4 socket

Quoted 7 lines · David Miller

From: Michael Kerrisk <[email protected]>
Date: Sat, 26 Jun 2010 15:01:03 +0200

Quoted 4 lines
Quoted 3 lines

 sent from this socket.
+.TP
+.BR IP_NODEFRAG " (since Linux 2.6)"

Quoted 6 lines
Quoted 2 lines

here, we'd write the exact version in which the flag is added. It looks like that might be 2.36, right?

It'll show up in 2.6.36

I doubt I'll be alive when we make it to 2.36 :-)

:) ok, attaching changed patch

thanks,
jirka

---
hi,

this patch adds description for IP_NODEFRAG option for IPv4 socket.

wbr,
jirka

---
 man7/ip.7 |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
man7/ip.7 +6 -0
index 34f7e80..12c0d5b 100644
@@ -705,6 +705,12 @@ socket option (see
 .BR IP_TTL " (since Linux 1.0)"
 Set or retrieve the current time-to-live field that is used in every packet
 sent from this socket.
+.TP
+.BR IP_NODEFRAG " (since Linux 2.6.36)"
+If enabled, the reassembly of outgoing packets is disabled in the netfilter layer.
+Only valid for
+.B SOCK_RAW
+sockets.
 .\" FIXME Document IP_XFRM_POLICY
 .\" Since Linux 2.5.48
 .\" Needs CAP_NET_ADMIN

A message that is not in the archive (sent off-list or not yet received): 20100626191315.GA2076-Wm2NNL2RFAC1BuvyT83C0lrZeV2/+9ztveTR/[email protected]

#10 lore raw

Re: [PATCH 2/2 v2] man - IP_NODEFRAG option for IPv4 socket

Hello Jiri

Quoted 8 lines · Jiri Olsa
Quoted 7 lines · David Miller

From: Michael Kerrisk <[email protected]>
Date: Sat, 26 Jun 2010 15:01:03 +0200

Quoted 4 lines
Quoted 3 lines

 sent from this socket.
+.TP
+.BR IP_NODEFRAG " (since Linux 2.6)"

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

here, we'd write the exact version in which the flag is added. It looks like that might be 2.36, right?

It'll show up in 2.6.36

I doubt I'll be alive when we make it to 2.36 :-)

:) ok, attaching changed patch

I tweaked that slightly, and applied the below for man-pages-3.27.

Thanks,

Michael

man7/ip.7 +0 -0
@@ -399,6 +399,14 @@ The default is 1 which means that multicast

packets don't leave the local
network unless the user program explicitly requests it. Argument is an integer.
.TP
+.BR IP_NODEFRAG " (since Linux 2.6.36)"
+If enabled (argument is nonzero),
+the reassembly of outgoing packets is disabled in the netfilter layer. +This option is only valid for
+.B SOCK_RAW
+sockets.
+The argument is an integer.
+.TP
.BR IP_OPTIONS " (since Linux 2.0)"
.\" Precisely: 1.3.30
Set or get the IP options to be sent with every packet from this socket.

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw
In reply to Jiri Olsa

hi,
any feedback?

thanks,
jirka

Quoted 16 lines · Jiri Olsa

hi,

this series contains patch for IP_NODEFRAG option for RAW sockets, and changes for man pages.

I'm sending this together, hope it's ok.

1/2 - net - IP_NODEFRAG option for IPv4 socket
2/2 - man - IP_NODEFRAG option for IPv4 socket

wbr,
jirka
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw
Quoted 3 lines · Jiri Olsa

hi,
any feedback?

Your patch seems fine to me.

Quoted 15 lines

thanks,
jirka

Quoted 10 lines · Jiri Olsa

hi,

this series contains patch for IP_NODEFRAG option for RAW sockets, and changes for man pages.

I'm sending this together, hope it's ok.

1/2 - net - IP_NODEFRAG option for IPv4 socket
2/2 - man - IP_NODEFRAG option for IPv4 socket