]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ipv6: Fix getsockopt() for sockets with default IPV6_AUTOFLOWLABEL
authorBen Hutchings <ben.hutchings@codethink.co.uk>
Mon, 22 Jan 2018 20:06:42 +0000 (20:06 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 24 Jan 2018 00:53:24 +0000 (19:53 -0500)
Commit 513674b5a2c9 ("net: reevalulate autoflowlabel setting after
sysctl setting") removed the initialisation of
ipv6_pinfo::autoflowlabel and added a second flag to indicate
whether this field or the net namespace default should be used.

The getsockopt() handling for this case was not updated, so it
currently returns 0 for all sockets for which IPV6_AUTOFLOWLABEL is
not explicitly enabled.  Fix it to return the effective value, whether
that has been set at the socket or net namespace level.

Fixes: 513674b5a2c9 ("net: reevalulate autoflowlabel setting after sysctl ...")
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ipv6.h
net/ipv6/ip6_output.c
net/ipv6/ipv6_sockglue.c

index f73797e2fa60c51a81c8d7a0e231bd2be0137119..221238254eb7837a1b57c6313b7a8f8fa83c0040 100644 (file)
@@ -331,6 +331,7 @@ int ipv6_flowlabel_opt_get(struct sock *sk, struct in6_flowlabel_req *freq,
                           int flags);
 int ip6_flowlabel_init(void);
 void ip6_flowlabel_cleanup(void);
+bool ip6_autoflowlabel(struct net *net, const struct ipv6_pinfo *np);
 
 static inline void fl6_sock_release(struct ip6_flowlabel *fl)
 {
index 4f7d8de56611472575862d50b9fd18f677d36e43..3763dc01e37477af36d4f1445d72d452e7528017 100644 (file)
@@ -166,7 +166,7 @@ int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
                            !(IP6CB(skb)->flags & IP6SKB_REROUTED));
 }
 
-static bool ip6_autoflowlabel(struct net *net, const struct ipv6_pinfo *np)
+bool ip6_autoflowlabel(struct net *net, const struct ipv6_pinfo *np)
 {
        if (!np->autoflowlabel_set)
                return ip6_default_np_autolabel(net);
index 2d4680e0376f41deee6c999eadaf9409353e0b4a..e8ffb5b5d84e626fdec748aeb2d3e284d6256db1 100644 (file)
@@ -1336,7 +1336,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
                break;
 
        case IPV6_AUTOFLOWLABEL:
-               val = np->autoflowlabel;
+               val = ip6_autoflowlabel(sock_net(sk), np);
                break;
 
        case IPV6_RECVFRAGSIZE: