Commit 7b2ff18e authored by Jiri Olsa's avatar Jiri Olsa Committed by David S. Miller

net - IP_NODEFRAG option for IPv4 socket

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.
Signed-off-by: default avatarJiri Olsa <jolsa@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 01fc3e86
...@@ -85,6 +85,7 @@ struct in_addr { ...@@ -85,6 +85,7 @@ struct in_addr {
#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR #define IP_RECVORIGDSTADDR IP_ORIGDSTADDR
#define IP_MINTTL 21 #define IP_MINTTL 21
#define IP_NODEFRAG 22
/* IP_MTU_DISCOVER values */ /* IP_MTU_DISCOVER values */
#define IP_PMTUDISC_DONT 0 /* Never send DF frames */ #define IP_PMTUDISC_DONT 0 /* Never send DF frames */
......
...@@ -137,7 +137,8 @@ struct inet_sock { ...@@ -137,7 +137,8 @@ struct inet_sock {
hdrincl:1, hdrincl:1,
mc_loop:1, mc_loop:1,
transparent:1, transparent:1,
mc_all:1; mc_all:1,
nodefrag:1;
int mc_index; int mc_index;
__be32 mc_addr; __be32 mc_addr;
struct ip_mc_socklist *mc_list; struct ip_mc_socklist *mc_list;
......
...@@ -355,6 +355,8 @@ static int inet_create(struct net *net, struct socket *sock, int protocol, ...@@ -355,6 +355,8 @@ static int inet_create(struct net *net, struct socket *sock, int protocol,
inet = inet_sk(sk); inet = inet_sk(sk);
inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0; inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0;
inet->nodefrag = 0;
if (SOCK_RAW == sock->type) { if (SOCK_RAW == sock->type) {
inet->inet_num = protocol; inet->inet_num = protocol;
if (IPPROTO_RAW == protocol) if (IPPROTO_RAW == protocol)
......
...@@ -465,7 +465,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -465,7 +465,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
(1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) | (1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) |
(1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) | (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) |
(1<<IP_PASSSEC) | (1<<IP_TRANSPARENT) | (1<<IP_PASSSEC) | (1<<IP_TRANSPARENT) |
(1<<IP_MINTTL))) || (1<<IP_MINTTL) | (1<<IP_NODEFRAG))) ||
optname == IP_MULTICAST_TTL || optname == IP_MULTICAST_TTL ||
optname == IP_MULTICAST_ALL || optname == IP_MULTICAST_ALL ||
optname == IP_MULTICAST_LOOP || optname == IP_MULTICAST_LOOP ||
...@@ -588,6 +588,13 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -588,6 +588,13 @@ static int do_ip_setsockopt(struct sock *sk, int level,
} }
inet->hdrincl = val ? 1 : 0; inet->hdrincl = val ? 1 : 0;
break; break;
case IP_NODEFRAG:
if (sk->sk_type != SOCK_RAW) {
err = -ENOPROTOOPT;
break;
}
inet->nodefrag = val ? 1 : 0;
break;
case IP_MTU_DISCOVER: case IP_MTU_DISCOVER:
if (val < IP_PMTUDISC_DONT || val > IP_PMTUDISC_PROBE) if (val < IP_PMTUDISC_DONT || val > IP_PMTUDISC_PROBE)
goto e_inval; goto e_inval;
......
...@@ -66,6 +66,11 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum, ...@@ -66,6 +66,11 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
const struct net_device *out, const struct net_device *out,
int (*okfn)(struct sk_buff *)) 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_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
#if !defined(CONFIG_NF_NAT) && !defined(CONFIG_NF_NAT_MODULE) #if !defined(CONFIG_NF_NAT) && !defined(CONFIG_NF_NAT_MODULE)
/* Previously seen (loopback)? Ignore. Do this before /* Previously seen (loopback)? Ignore. Do this before
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment