summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2018-10-16 03:00:28 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2018-10-16 03:00:28 +0000
commit489561a43e1c8d9ff451f17dc549a254c5f7b0c1 (patch)
treeac43f72be051fbc8da4d21b82a29cf92bbca71c7 /sys/net
parent8e2a7700aa87f6457d8fd7eda1b74690ac6cf810 (diff)
pull and put the traffic class in ipv6 headers
this gives ipv6 handling equivalent the tos stuff in ipv4. ok visa@ benno@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_gre.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index 1c9a9bda44d..143db4e39c3 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gre.c,v 1.124 2018/07/24 07:40:35 yasuoka Exp $ */
+/* $OpenBSD: if_gre.c,v 1.125 2018/10/16 03:00:27 dlg Exp $ */
/* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
@@ -1896,11 +1896,20 @@ gre_l3_encap_dst(const struct gre_tunnel *tunnel, const void *dst,
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 *tunnel, const union gre_addr *dst,
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;