route: Support ToS/DiffServ priority inheritance when routing IPv6 packets.
authorVittorio Gambaletta (VittGam) <github@vittgam.net>
Wed, 12 Oct 2016 11:52:17 +0000 (13:52 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Mon, 20 Mar 2017 21:38:59 +0000 (22:38 +0100)
Signed-off-by: Vittorio Gambaletta <openwrt@vittgam.net>
src/route.c

index 0c9f2aa11e0f0a6ca5e1624c1645b5bed9b5fd33..c10fddb5e289b0a29da2d974746e6d30b1fa0395 100644 (file)
@@ -683,6 +683,9 @@ static void route_ipv6(node_t *source, vpn_packet_t *packet) {
                if(!do_decrement_ttl(source, packet))
                        return;
 
+       if(priorityinheritance)
+               packet->priority = ((DATA(packet)[14] & 0x0f) << 4) | (DATA(packet)[15] >> 4);
+
        via = (subnet->owner->via == myself) ? subnet->owner->nexthop : subnet->owner->via;
 
        if(via == source) {
@@ -954,8 +957,12 @@ static void route_mac(node_t *source, vpn_packet_t *packet) {
 
        uint16_t type = DATA(packet)[12] << 8 | DATA(packet)[13];
 
-       if(priorityinheritance && type == ETH_P_IP && packet->len >= ether_size + ip_size)
-               packet->priority = DATA(packet)[15];
+       if(priorityinheritance) {
+               if(type == ETH_P_IP && packet->len >= ether_size + ip_size)
+                       packet->priority = DATA(packet)[15];
+               else if(type == ETH_P_IPV6 && packet->len >= ether_size + ip6_size)
+                       packet->priority = ((DATA(packet)[14] & 0x0f) << 4) | (DATA(packet)[15] >> 4);
+       }
 
        // Handle packets larger than PMTU