Skip to content

Commit

Permalink
Merge pull request #1183 from dpino/ipv6-flow-label
Browse files Browse the repository at this point in the history
Allow setting flow-label in ingress packets
  • Loading branch information
dpino committed Oct 14, 2018
2 parents 33d03cf + 14690f2 commit 4b3e5ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/apps/lwaftr/lwaftr.lua
Expand Up @@ -217,12 +217,12 @@ local function prepend_ethernet_header(pkt, ether_type)
return pkt
end

local function write_ipv6_header(ptr, src, dst, tc, next_header, payload_length)
local function write_ipv6_header(ptr, src, dst, tc, flow_label, next_header, payload_length)
local h = ffi.cast(ipv6_header_ptr_t, ptr)
h.v_tc_fl = 0
lib.bitfield(32, h, 'v_tc_fl', 0, 4, 6) -- IPv6 Version
lib.bitfield(32, h, 'v_tc_fl', 4, 8, tc) -- Traffic class
lib.bitfield(32, h, 'v_tc_fl', 12, 20, 0) -- Flow label
lib.bitfield(32, h, 'v_tc_fl', 12, 20, flow_label) -- Flow label
h.payload_length = htons(payload_length)
h.next_header = next_header
h.hop_limit = constants.default_ttl
Expand Down Expand Up @@ -740,14 +740,15 @@ function LwAftr:encapsulate_and_transmit(pkt, ipv6_dst, ipv6_src, pkt_src_link)
local payload_length = get_ethernet_payload_length(pkt)
local l3_header = get_ethernet_payload(pkt)
local traffic_class = get_ipv4_dscp_and_ecn(l3_header)
local flow_label = self.conf.internal_interface.flow_label
-- Note that this may invalidate any pointer into pkt.data. Be warned!
pkt = packet.shiftright(pkt, ipv6_header_size)
write_ethernet_header(pkt, n_ethertype_ipv6)
-- Fetch possibly-moved L3 header location.
l3_header = get_ethernet_payload(pkt)

write_ipv6_header(l3_header, ipv6_src, ipv6_dst, traffic_class,
proto_ipv4, payload_length)
flow_label, proto_ipv4, payload_length)

if debug then
print("encapsulated packet:")
Expand Down
7 changes: 7 additions & 0 deletions src/lib/yang/snabb-softwire-v2.yang
Expand Up @@ -723,6 +723,13 @@ module snabb-softwire-v2 {
"Maximum packet size to recieve on the IPv6 interface.";
}

leaf flow-label {
type uint32;
default 0;
description
"IPv6 flow label";
}

uses traffic-filters;
uses icmp-policy;
uses vlan-tagging;
Expand Down

0 comments on commit 4b3e5ae

Please sign in to comment.