* [PATCH net-next] ipv6: add IPV6_HDRINCL option for raw sockets
@ 2015-12-16 16:22 Hannes Frederic Sowa
2015-12-16 19:01 ` Joe Perches
2015-12-17 20:12 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Hannes Frederic Sowa @ 2015-12-16 16:22 UTC (permalink / raw)
To: netdev
Same as in Windows, we miss IPV6_HDRINCL for SOL_IPV6 and SOL_RAW.
The SOL_IP/IP_HDRINCL is not available for IPv6 sockets.
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
include/uapi/linux/in6.h | 1 +
net/ipv6/raw.c | 20 ++++++++++++++++----
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/include/uapi/linux/in6.h b/include/uapi/linux/in6.h
index 79b12b004ade03..318a4828bf98c2 100644
--- a/include/uapi/linux/in6.h
+++ b/include/uapi/linux/in6.h
@@ -196,6 +196,7 @@ struct in6_flowlabel_req {
#define IPV6_IPSEC_POLICY 34
#define IPV6_XFRM_POLICY 35
+#define IPV6_HDRINCL 36
#endif
/*
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 99140986e88716..fa59dd7a427e88 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -972,6 +972,11 @@ static int do_rawv6_setsockopt(struct sock *sk, int level, int optname,
return -EFAULT;
switch (optname) {
+ case IPV6_HDRINCL:
+ if (sk->sk_type != SOCK_RAW)
+ return -EINVAL;
+ inet_sk(sk)->hdrincl = !!val;
+ return 0;
case IPV6_CHECKSUM:
if (inet_sk(sk)->inet_num == IPPROTO_ICMPV6 &&
level == IPPROTO_IPV6) {
@@ -1016,7 +1021,8 @@ static int rawv6_setsockopt(struct sock *sk, int level, int optname,
return -EOPNOTSUPP;
return rawv6_seticmpfilter(sk, level, optname, optval, optlen);
case SOL_IPV6:
- if (optname == IPV6_CHECKSUM)
+ if (optname == IPV6_CHECKSUM ||
+ optname == IPV6_HDRINCL)
break;
default:
return ipv6_setsockopt(sk, level, optname, optval, optlen);
@@ -1037,7 +1043,8 @@ static int compat_rawv6_setsockopt(struct sock *sk, int level, int optname,
return -EOPNOTSUPP;
return rawv6_seticmpfilter(sk, level, optname, optval, optlen);
case SOL_IPV6:
- if (optname == IPV6_CHECKSUM)
+ if (optname == IPV6_CHECKSUM ||
+ optname == IPV6_HDRINCL)
break;
default:
return compat_ipv6_setsockopt(sk, level, optname,
@@ -1057,6 +1064,9 @@ static int do_rawv6_getsockopt(struct sock *sk, int level, int optname,
return -EFAULT;
switch (optname) {
+ case IPV6_HDRINCL:
+ val = inet_sk(sk)->hdrincl;
+ break;
case IPV6_CHECKSUM:
/*
* We allow getsockopt() for IPPROTO_IPV6-level
@@ -1094,7 +1104,8 @@ static int rawv6_getsockopt(struct sock *sk, int level, int optname,
return -EOPNOTSUPP;
return rawv6_geticmpfilter(sk, level, optname, optval, optlen);
case SOL_IPV6:
- if (optname == IPV6_CHECKSUM)
+ if (optname == IPV6_CHECKSUM ||
+ optname == IPV6_HDRINCL)
break;
default:
return ipv6_getsockopt(sk, level, optname, optval, optlen);
@@ -1115,7 +1126,8 @@ static int compat_rawv6_getsockopt(struct sock *sk, int level, int optname,
return -EOPNOTSUPP;
return rawv6_geticmpfilter(sk, level, optname, optval, optlen);
case SOL_IPV6:
- if (optname == IPV6_CHECKSUM)
+ if (optname == IPV6_CHECKSUM ||
+ optname == IPV6_HDRINCL)
break;
default:
return compat_ipv6_getsockopt(sk, level, optname,
--
2.5.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ipv6: add IPV6_HDRINCL option for raw sockets
2015-12-16 16:22 [PATCH net-next] ipv6: add IPV6_HDRINCL option for raw sockets Hannes Frederic Sowa
@ 2015-12-16 19:01 ` Joe Perches
2015-12-17 20:12 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2015-12-16 19:01 UTC (permalink / raw)
To: Hannes Frederic Sowa, netdev
On Wed, 2015-12-16 at 17:22 +0100, Hannes Frederic Sowa wrote:
> Same as in Windows, we miss IPV6_HDRINCL for SOL_IPV6 and SOL_RAW.
> The SOL_IP/IP_HDRINCL is not available for IPv6 sockets.
[]
> diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
[]
> @@ -972,6 +972,11 @@ static int do_rawv6_setsockopt(struct sock *sk,
> int level, int optname,
> return -EFAULT;
>
> switch (optname) {
> + case IPV6_HDRINCL:
> + if (sk->sk_type != SOCK_RAW)
> + return -EINVAL;
> + inet_sk(sk)->hdrincl = !!val;
trivia:
ipv4/sockglue.c uses the ternary '? 1 : 0' convention for this.
It might be nicer to be consistent.
Then again sockglue.c is inconsistent about that too.
net/ipv4/ip_sockglue.c:736: inet->hdrincl = val ? 1 : 0;
net/ipv4/ip_sockglue.c:743: inet->nodefrag = val ? 1 : 0;
net/ipv4/ip_sockglue.c:746: inet->bind_address_no_port = val ? 1 : 0;
net/ipv4/ip_sockglue.c:754: inet->recverr = !!val;
net/ipv4/ip_sockglue.c:772: inet->mc_loop = !!val;
net/ipv4/ip_sockglue.c:1123: inet->freebind = !!val;
There's no change to object code either way.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ipv6: add IPV6_HDRINCL option for raw sockets
2015-12-16 16:22 [PATCH net-next] ipv6: add IPV6_HDRINCL option for raw sockets Hannes Frederic Sowa
2015-12-16 19:01 ` Joe Perches
@ 2015-12-17 20:12 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2015-12-17 20:12 UTC (permalink / raw)
To: hannes; +Cc: netdev
From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Wed, 16 Dec 2015 17:22:47 +0100
> Same as in Windows, we miss IPV6_HDRINCL for SOL_IPV6 and SOL_RAW.
> The SOL_IP/IP_HDRINCL is not available for IPv6 sockets.
>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
This looks fine, applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-17 20:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-16 16:22 [PATCH net-next] ipv6: add IPV6_HDRINCL option for raw sockets Hannes Frederic Sowa
2015-12-16 19:01 ` Joe Perches
2015-12-17 20:12 ` David 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).