]> Git Repo - linux.git/commitdiff
ip6_gre: set DSCP for non-IP
authorMatthias May <[email protected]>
Mon, 11 Jul 2022 09:17:20 +0000 (11:17 +0200)
committerDavid S. Miller <[email protected]>
Wed, 13 Jul 2022 11:10:22 +0000 (12:10 +0100)
The current code always forces a dscp of 0 for all non-IP frames.
However when setting a specific TOS with the command

ip link add name tep0 type ip6gretap local fdd1:ced0:5d88:3fce::1
remote fdd1:ced0:5d88:3fce::2 tos 0xa0

one would expect all GRE encapsulated frames to have a TOS of 0xA0.
and not only when the payload is IPv4/IPv6.

Signed-off-by: Matthias May <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
net/ipv6/ip6_gre.c

index 1bd10ae332e8a38903fc377d81781d3ed3513f21..f0aeca609ab7859152507018804316083f75646b 100644 (file)
@@ -701,6 +701,33 @@ static int prepare_ip6gre_xmit_ipv6(struct sk_buff *skb,
        return 0;
 }
 
+static int prepare_ip6gre_xmit_other(struct sk_buff *skb,
+                                    struct net_device *dev,
+                                    struct flowi6 *fl6, __u8 *dsfield,
+                                    int *encap_limit)
+{
+       struct ip6_tnl *t = netdev_priv(dev);
+
+       if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
+               *encap_limit = t->parms.encap_limit;
+
+       memcpy(fl6, &t->fl.u.ip6, sizeof(*fl6));
+
+       if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
+               *dsfield = 0;
+       else
+               *dsfield = ip6_tclass(t->parms.flowinfo);
+
+       if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
+               fl6->flowi6_mark = skb->mark;
+       else
+               fl6->flowi6_mark = t->parms.fwmark;
+
+       fl6->flowi6_uid = sock_net_uid(dev_net(dev), NULL);
+
+       return 0;
+}
+
 static struct ip_tunnel_info *skb_tunnel_info_txcheck(struct sk_buff *skb)
 {
        struct ip_tunnel_info *tun_info;
@@ -868,20 +895,18 @@ static int ip6gre_xmit_other(struct sk_buff *skb, struct net_device *dev)
        struct ip6_tnl *t = netdev_priv(dev);
        int encap_limit = -1;
        struct flowi6 fl6;
+       __u8 dsfield = 0;
        __u32 mtu;
        int err;
 
-       if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
-               encap_limit = t->parms.encap_limit;
-
-       if (!t->parms.collect_md)
-               memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
+       if (!t->parms.collect_md &&
+           prepare_ip6gre_xmit_other(skb, dev, &fl6, &dsfield, &encap_limit))
+               return -1;
 
        err = gre_handle_offloads(skb, !!(t->parms.o_flags & TUNNEL_CSUM));
        if (err)
                return err;
-
-       err = __gre6_xmit(skb, dev, 0, &fl6, encap_limit, &mtu, skb->protocol);
+       err = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu, skb->protocol);
 
        return err;
 }
This page took 0.059712 seconds and 4 git commands to generate.