From bd3ff678b733964c689b52ff1b0d2c838edeb8b8 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Thu, 17 Dec 2020 18:30:16 +0100 Subject: xdp: T2666: initial XDP (generic mode) forwarding support The CLI command 'set interfaces ethernet offload-options xdp" enables the XDP generic mode on the given interface. vyos@vyos:~$ show interfaces ethernet eth1 eth1: mtu 1500 xdpgeneric/id:151 qdisc mq state DOWN group default qlen 1000 link/ether 00:50:56:bf:ef:aa brd ff:ff:ff:ff:ff:ff inet6 fe80::250:56ff:febf:efaa/64 scope link tentative valid_lft forever preferred_lft forever Description: fooa XDP code is thankfully copied from [1], thank you for this nice tutorial. NOTE: this is an experimental feature which might break your forwarding/filtering. [1]: https://medium.com/swlh/building-a-xdp-express-data-path-based-peering-router-20db4995da66 --- python/vyos/ifconfig/ethernet.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'python/vyos') diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py index 12d1ec265..1bc63eec2 100644 --- a/python/vyos/ifconfig/ethernet.py +++ b/python/vyos/ifconfig/ethernet.py @@ -251,6 +251,23 @@ class EthernetIf(Interface): """ return self.set_interface('ufo', state) + def set_xdp(self, enabled): + """ + """ + ifname = self.config['ifname'] + cmd = f'ip link set dev {ifname} xdp off' + if enabled: + # use 'xdpgeneric' for the time beeing until we can detect supported + # drivers or have a lookup table of whatever kind. This then can be + # replaced by xdpdrv + cmd = f'ip -force link set dev {ifname} xdpgeneric obj /usr/share/vyos/ebpf/xdp_router.o' + try: + return self._cmd(cmd) + except: + from vyos import ConfigError + raise ConfigError('Error: Device does not allow enslaving to a bridge.') + + def set_ring_buffer(self, b_type, b_size): """ Example: @@ -306,6 +323,10 @@ class EthernetIf(Interface): value = tmp if (tmp != None) else 'off' self.set_ufo(value) + # UDP fragmentation offloading + tmp = dict_search('offload_options.xdp', config) + self.set_xdp(tmp != None) # enable or disable + # Set physical interface speed and duplex if {'speed', 'duplex'} <= set(config): speed = config.get('speed') -- cgit v1.2.3