ipv6: yet another new IPV6_MTU_DISCOVER option IPV6_PMTUDISC_OMIT
authorHannes Frederic Sowa <hannes@stressinduktion.org>
Wed, 26 Feb 2014 00:20:43 +0000 (01:20 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Feb 2014 20:51:01 +0000 (15:51 -0500)
This option has the same semantic as IP_PMTUDISC_OMIT for IPv4 which
got recently introduced. It doesn't honor the path mtu discovered by the
host but in contrary to IPV6_PMTUDISC_INTERFACE allows the generation of
fragments if the packet size exceeds the MTU of the outgoing interface
MTU.

Fixes: 93b36cf3425b9b ("ipv6: support IPV6_PMTU_INTERFACE on sockets")
Cc: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ip6_route.h
include/uapi/linux/in6.h
net/ipv6/ip6_output.c
net/ipv6/ipv6_sockglue.c

index 017badb1aec7e8648a6f71d473862b730a78b4e8..00e3f12cb2f94dfd0755581f6c48bc165a469588 100644 (file)
@@ -171,7 +171,14 @@ static inline int ip6_skb_dst_mtu(struct sk_buff *skb)
 
 static inline bool ip6_sk_accept_pmtu(const struct sock *sk)
 {
-       return inet6_sk(sk)->pmtudisc != IPV6_PMTUDISC_INTERFACE;
+       return inet6_sk(sk)->pmtudisc != IPV6_PMTUDISC_INTERFACE &&
+              inet6_sk(sk)->pmtudisc != IPV6_PMTUDISC_OMIT;
+}
+
+static inline bool ip6_sk_local_df(const struct sock *sk)
+{
+       return inet6_sk(sk)->pmtudisc < IPV6_PMTUDISC_DO ||
+              inet6_sk(sk)->pmtudisc == IPV6_PMTUDISC_OMIT;
 }
 
 static inline struct in6_addr *rt6_nexthop(struct rt6_info *rt)
index e9a1d2d973b6aef256808d248d007804a689a1df..0d8e0f0342dc183acd5393e11bfe203f019ca165 100644 (file)
@@ -185,6 +185,10 @@ struct in6_flowlabel_req {
  * also see comments on IP_PMTUDISC_INTERFACE
  */
 #define IPV6_PMTUDISC_INTERFACE                4
+/* weaker version of IPV6_PMTUDISC_INTERFACE, which allows packets to
+ * get fragmented if they exceed the interface mtu
+ */
+#define IPV6_PMTUDISC_OMIT             5
 
 /* Flowlabel */
 #define IPV6_FLOWLABEL_MGR     32
index 070a2fae2375cd5f6c4ad8109887dc6236ee5b08..be1b7f5a3a5485d8628eafe8f1ec8a3472836e43 100644 (file)
@@ -1234,8 +1234,10 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
                              sizeof(struct frag_hdr) : 0) +
                             rt->rt6i_nfheader_len;
 
-               maxnonfragsize = (np->pmtudisc >= IPV6_PMTUDISC_DO) ?
-                                mtu : sizeof(struct ipv6hdr) + IPV6_MAXPLEN;
+               if (ip6_sk_local_df(sk))
+                       maxnonfragsize = sizeof(struct ipv6hdr) + IPV6_MAXPLEN;
+               else
+                       maxnonfragsize = mtu;
 
                /* dontfrag active */
                if ((cork->length + length > mtu - headersize) && dontfrag &&
@@ -1543,8 +1545,7 @@ int ip6_push_pending_frames(struct sock *sk)
        }
 
        /* Allow local fragmentation. */
-       if (np->pmtudisc < IPV6_PMTUDISC_DO)
-               skb->local_df = 1;
+       skb->local_df = ip6_sk_local_df(sk);
 
        *final_dst = fl6->daddr;
        __skb_pull(skb, skb_network_header_len(skb));
index 0a00f449de5e0484686f008e792b27efd67d2356..edb58aff4ae70ac864f3f2b559815064f4db87f6 100644 (file)
@@ -722,7 +722,7 @@ done:
        case IPV6_MTU_DISCOVER:
                if (optlen < sizeof(int))
                        goto e_inval;
-               if (val < IPV6_PMTUDISC_DONT || val > IPV6_PMTUDISC_INTERFACE)
+               if (val < IPV6_PMTUDISC_DONT || val > IPV6_PMTUDISC_OMIT)
                        goto e_inval;
                np->pmtudisc = val;
                retv = 0;