Skip to contentSkip to conversation

bpf: add End.DT6 action to bpf_lwt_seg6_action helper

PATCH Applied Mathieu Xhonneux 2 participants 2 messages Jul 26, 2018 – Jul 31, 2018

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 bpf: add End.DT6 action to bpf_lwt_seg6_action helper

The seg6local LWT provides the End.DT6 action, which allows to decapsulate an outer IPv6 header containing a Segment Routing Header (SRH), full specification is available here:

https://tools.ietf.org/html/draft-filsfils-spring-srv6-network-programming-05

This patch adds this action now to the seg6local BPF interface. Since it is not mandatory that the inner IPv6 header also contains a SRH, seg6_bpf_srh_state has been extended with a pointer to a possible SRH of the outermost IPv6 header. This helps assessing if the validation must be triggered or not, and avoids some calls to ipv6_find_hdr.

v3: s/1/true, s/0/false for boolean values
v2: - changed true/false -> 1/0
- preempt_enable no longer called in first conditional block

---
 include/net/seg6_local.h |  4 ++-
 net/core/filter.c        | 89 ++++++++++++++++++++++++++++++++----------------
 net/ipv6/seg6_local.c    | 50 +++++++++++++++++----------
 3 files changed, 95 insertions(+), 48 deletions(-)
include/net/seg6_local.h +3 -1
index 661fd5b4d3e0..08359e2d8b35 100644
@@ -21,10 +21,12 @@
 
 extern int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
 			       u32 tbl_id);
+extern bool seg6_bpf_has_valid_srh(struct sk_buff *skb);
 
 struct seg6_bpf_srh_state {
-	bool valid;
+	struct ipv6_sr_hdr *srh;
 	u16 hdrlen;
+	bool valid;
 };
 
 DECLARE_PER_CPU(struct seg6_bpf_srh_state, seg6_bpf_srh_states);
net/core/filter.c +60 -29

161 lines not on this page · raw message

net/ipv6/seg6_local.c +32 -18

92 lines not on this page · raw message

Signature · 1 line
2.16.1
maintainer Applied
#1 lore raw
Quoted 13 lines · Mathieu Xhonneux

The seg6local LWT provides the End.DT6 action, which allows to decapsulate an outer IPv6 header containing a Segment Routing Header (SRH), full specification is available here:

https://tools.ietf.org/html/draft-filsfils-spring-srv6-network-programming-05

This patch adds this action now to the seg6local BPF interface. Since it is not mandatory that the inner IPv6 header also contains a SRH, seg6_bpf_srh_state has been extended with a pointer to a possible SRH of the outermost IPv6 header. This helps assessing if the validation must be triggered or not, and avoids some calls to ipv6_find_hdr.

Quoted 5 lines

v3: s/1/true, s/0/false for boolean values
v2: - changed true/false -> 1/0
- preempt_enable no longer called in first conditional block

Applied to bpf-next, thanks Mathieu!