History

bpf: Add flag BPF_F_NO_TUNNEL_KEY to bpf_skb_set_tunnel_key()

This patch allows to remove TUNNEL_KEY from the tunnel flags bitmap when using bpf_skb_set_tunnel_key by providing a BPF_F_NO_TUNNEL_KEY flag. On egress, the resulting tunnel header will not contain a tunnel key if the protocol and implementation supports it. At the moment bpf_tunnel_key wants a user to specify a numeric tunnel key. This will wrap the inner packet into a tunnel header with the key bit and value set accordingly. This is problematic when using a tunnel protocol that supports optional tunnel keys and a receiving tunnel device that is not expecting packets with the key bit set. The receiver won't decapsulate and drop the packet. RFC 2890 and RFC 2784 GRE tunnels are examples where this flag is useful. It allows for generating packets, that can be decapsulated by a GRE tunnel device not operating in collect metadata mode or not expecting the key bit set.

Christian Ehrig committed 3 years ago

Commit e26aa601 parent 64f46603 files · +12 −1Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/linux/bpf.h+4−0
@@ -2001,6 +2001,9 @@ union bpf_attr { · 2000 unmodified lines
2001 * sending the packet. This flag was added for GRE2001 * sending the packet. This flag was added for GRE
2002 * encapsulation, but might be used with other protocols2002 * encapsulation, but might be used with other protocols
2003 * as well in the future.2003 * as well in the future.
2004 * **BPF_F_NO_TUNNEL_KEY**
2005 * Add a flag to tunnel metadata indicating that no tunnel
2006 * key should be set in the resulting tunnel header.
2004 *2007 *
2005 * Here is a typical usage on the transmit path:2008 * Here is a typical usage on the transmit path:
2006 *2009 *
@@ -5764,6 +5767,7 @@ enum { · 3757 unmodified lines
5764 BPF_F_ZERO_CSUM_TX = (1ULL << 1),5767 BPF_F_ZERO_CSUM_TX = (1ULL << 1),
5765 BPF_F_DONT_FRAGMENT = (1ULL << 2),5768 BPF_F_DONT_FRAGMENT = (1ULL << 2),
5766 BPF_F_SEQ_NUMBER = (1ULL << 3),5769 BPF_F_SEQ_NUMBER = (1ULL << 3),
5770 BPF_F_NO_TUNNEL_KEY = (1ULL << 4),
5767};5771};
5768 5772
5769/* BPF_FUNC_skb_get_tunnel_key flags. */5773/* BPF_FUNC_skb_get_tunnel_key flags. */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t