OffloadUtils - implement tcFilterAddDevIngressTether()
Test: build
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7e8ebaaff28100d5a0179da1b9bccbf09c91c098
diff --git a/server/OffloadUtils.cpp b/server/OffloadUtils.cpp
index 20f0496..b374722 100644
--- a/server/OffloadUtils.cpp
+++ b/server/OffloadUtils.cpp
@@ -215,23 +215,39 @@
// (also compatible with anything that has standard ethernet header)
static constexpr char name_clat_tx_ether[] = CLAT_EGRESS_PROG_ETHER_NAME FSOBJ_SUFFIX;
+ // This macro expands (from header files) to:
+ // prog_offload_schedcls_ingress_tether_rawip:[*fsobj]
+ // and is the name of the pinned ingress ebpf program for ARPHRD_RAWIP interfaces.
+ // (also compatible with anything that has 0 size L2 header)
+ static constexpr char name_tether_rawip[] = TETHER_INGRESS_PROG_RAWIP_NAME FSOBJ_SUFFIX;
+
+ // This macro expands (from header files) to:
+ // prog_offload_schedcls_ingress_tether_ether:[*fsobj]
+ // and is the name of the pinned ingress ebpf program for ARPHRD_ETHER interfaces.
+ // (also compatible with anything that has standard ethernet header)
+ static constexpr char name_tether_ether[] = TETHER_INGRESS_PROG_ETHER_NAME FSOBJ_SUFFIX;
+
#undef FSOBJ_SUFFIX
// The actual name we'll use is determined at run time via 'ethernet' and 'ingress'
// booleans. We need to compile time allocate enough space in the struct
// hence this macro magic to make sure we have enough space for either
// possibility. In practice some of these are actually the same size.
- static constexpr size_t ASCIIZ_MAXLEN_NAME_CLAT_RX =
- max(sizeof(name_clat_rx_rawip), sizeof(name_clat_rx_ether));
- static constexpr size_t ASCIIZ_MAXLEN_NAME_CLAT_TX =
- max(sizeof(name_clat_tx_rawip), sizeof(name_clat_tx_ether));
- static constexpr size_t ASCIIZ_MAXLEN_NAME =
- max(ASCIIZ_MAXLEN_NAME_CLAT_RX, ASCIIZ_MAXLEN_NAME_CLAT_TX);
+ static constexpr size_t ASCIIZ_MAXLEN_NAME = max({
+ sizeof(name_clat_rx_rawip),
+ sizeof(name_clat_rx_ether),
+ sizeof(name_clat_tx_rawip),
+ sizeof(name_clat_tx_ether),
+ sizeof(name_tether_rawip),
+ sizeof(name_tether_ether),
+ });
// These are not compile time constants: 'name' is used in strncpy below
const char* const name_clat_rx = ethernet ? name_clat_rx_ether : name_clat_rx_rawip;
const char* const name_clat_tx = ethernet ? name_clat_tx_ether : name_clat_tx_rawip;
- const char* const name = ingress ? name_clat_rx : name_clat_tx;
+ const char* const name_clat = ingress ? name_clat_rx : name_clat_tx;
+ const char* const name_tether = ethernet ? name_tether_ether : name_tether_rawip;
+ const char* const name = (prio == PRIO_TETHER) ? name_tether : name_clat;
struct {
nlmsghdr n;