pretty straightforward...
ok?
Index: if_gre.c
===================================================================
RCS file: /cvs/src/sys/net/if_gre.c,v
retrieving revision 1.124
diff -u -p -r1.124 if_gre.c
--- if_gre.c 24 Jul 2018 07:40:35 -0000 1.124
+++ if_gre.c 13 Oct 2018 21:57:23 -0000
@@ -1896,11 +1896,20 @@ gre_l3_encap_dst(const struct gre_tunnel
break;
}
#ifdef INET6
- case AF_INET6:
- tos = 0;
+ case AF_INET6: {
+ struct ip6_hdr *ip6;
+
+ m = m_pullup(m, sizeof(*ip6));
+ if (m == NULL)
+ return (NULL);
+
+ ip6 = mtod(m, struct ip6_hdr *);
+ tos = (ntohl(ip6->ip6_flow) & 0x0ff00000) >> 20;
+
ttloff = offsetof(struct ip6_hdr, ip6_hlim);
proto = htons(ETHERTYPE_IPV6);
break;
+ }
#endif
#ifdef MPLS
case AF_MPLS:
@@ -2001,6 +2010,7 @@ gre_encap_dst_ip(const struct gre_tunnel
ip6->ip6_flow = ISSET(m->m_pkthdr.ph_flowid, M_FLOWID_VALID) ?
htonl(m->m_pkthdr.ph_flowid & M_FLOWID_MASK) : 0;
ip6->ip6_vfc |= IPV6_VERSION;
+ ip6->ip6_flow |= htonl((uint32_t)tos << 20);
ip6->ip6_plen = htons(len);
ip6->ip6_nxt = IPPROTO_GRE;
ip6->ip6_hlim = ttl;