net/ipv4: Introduce IPSKB_FRAG_SEGS bit to inet_skb_parm.flags
authorShmulik Ladkani <shmulik.ladkani@gmail.com>
Mon, 18 Jul 2016 11:49:33 +0000 (14:49 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 19 Jul 2016 23:40:22 +0000 (16:40 -0700)
This flag indicates whether fragmentation of segments is allowed.

Formerly this policy was hardcoded according to IPSKB_FORWARDED (set by
either ip_forward or ipmr_forward).

Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Florian Westphal <fw@strlen.de>
Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ip.h
net/ipv4/ip_forward.c
net/ipv4/ip_output.c
net/ipv4/ipmr.c

index 08f36cd2b874b5493bc9b51c4071722591dcc321..9742b92dc93386ea1e8cc86911feecd0f650fa9e 100644 (file)
@@ -47,6 +47,7 @@ struct inet_skb_parm {
 #define IPSKB_REROUTED         BIT(4)
 #define IPSKB_DOREDIRECT       BIT(5)
 #define IPSKB_FRAG_PMTU                BIT(6)
+#define IPSKB_FRAG_SEGS                BIT(7)
 
        u16                     frag_max_size;
 };
index 9f0a7b96646f368021d9cd51bc3f728ba49eed0d..8b4ffd2168395b4d3b6ec67e166af13c122128ca 100644 (file)
@@ -117,7 +117,7 @@ int ip_forward(struct sk_buff *skb)
        if (opt->is_strictroute && rt->rt_uses_gateway)
                goto sr_failed;
 
-       IPCB(skb)->flags |= IPSKB_FORWARDED;
+       IPCB(skb)->flags |= IPSKB_FORWARDED | IPSKB_FRAG_SEGS;
        mtu = ip_dst_mtu_maybe_forward(&rt->dst, true);
        if (ip_exceeds_mtu(skb, mtu)) {
                IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
index e23f141c9ba5033d0848813f4548fc61af88e082..dde37fb340bf90cdbba48489922f2c61b110066d 100644 (file)
@@ -223,8 +223,10 @@ static int ip_finish_output_gso(struct net *net, struct sock *sk,
        struct sk_buff *segs;
        int ret = 0;
 
-       /* common case: locally created skb or seglen is <= mtu */
-       if (((IPCB(skb)->flags & IPSKB_FORWARDED) == 0) ||
+       /* common case: fragmentation of segments is not allowed,
+        * or seglen is <= mtu
+        */
+       if (((IPCB(skb)->flags & IPSKB_FRAG_SEGS) == 0) ||
              skb_gso_validate_mtu(skb, mtu))
                return ip_finish_output2(net, sk, skb);
 
index e0d76f5f011328f7abe180dc28d47efaa834107e..eec234161b890d564f00a58eb4dfd0545d30ad34 100644 (file)
@@ -1749,7 +1749,7 @@ static void ipmr_queue_xmit(struct net *net, struct mr_table *mrt,
                vif->dev->stats.tx_bytes += skb->len;
        }
 
-       IPCB(skb)->flags |= IPSKB_FORWARDED;
+       IPCB(skb)->flags |= IPSKB_FORWARDED | IPSKB_FRAG_SEGS;
 
        /* RFC1584 teaches, that DVMRP/PIM router must deliver packets locally
         * not only before forwarding, but after forwarding on all output