DscpPolicy: match_policy is_eth is always true
The raw IP program was removed, so there is no need to support it
anymore in match_policy().
Test: TH
Bug: 235559605
Change-Id: I755a9a55e3ad33a210145b2cc09578fdf4d66c79
diff --git a/bpf_progs/dscpPolicy.c b/bpf_progs/dscpPolicy.c
index a672c75..d3e7b38 100644
--- a/bpf_progs/dscpPolicy.c
+++ b/bpf_progs/dscpPolicy.c
@@ -53,12 +53,12 @@
DEFINE_BPF_MAP_GRW(ipv4_dscp_policies_map, ARRAY, uint32_t, DscpPolicy, MAX_POLICIES, AID_SYSTEM)
DEFINE_BPF_MAP_GRW(ipv6_dscp_policies_map, ARRAY, uint32_t, DscpPolicy, MAX_POLICIES, AID_SYSTEM)
-static inline __always_inline void match_policy(struct __sk_buff* skb, bool ipv4, bool is_eth) {
+static inline __always_inline void match_policy(struct __sk_buff* skb, bool ipv4) {
void* data = (void*)(long)skb->data;
const void* data_end = (void*)(long)skb->data_end;
- const int l2_header_size = is_eth ? sizeof(struct ethhdr) : 0;
- struct ethhdr* eth = is_eth ? data : NULL;
+ const int l2_header_size = sizeof(struct ethhdr);
+ struct ethhdr* eth = data;
if (data + l2_header_size > data_end) return;
@@ -84,7 +84,7 @@
uint8_t priority = 0; // Only used for IPv6
uint8_t flow_lbl = 0; // Only used for IPv6
if (ipv4) {
- const struct iphdr* const iph = is_eth ? (void*)(eth + 1) : data;
+ const struct iphdr* const iph = (void*)(eth + 1);
hdr_size = l2_header_size + sizeof(struct iphdr);
// Must have ipv4 header
if (data + hdr_size > data_end) return;
@@ -105,7 +105,7 @@
protocol = iph->protocol;
tos = iph->tos;
} else {
- struct ipv6hdr* ip6h = is_eth ? (void*)(eth + 1) : data;
+ struct ipv6hdr* ip6h = (void*)(eth + 1);
hdr_size = l2_header_size + sizeof(struct ipv6hdr);
// Must have ipv6 header
if (data + hdr_size > data_end) return;
@@ -293,9 +293,9 @@
if (skb->pkt_type != PACKET_HOST) return TC_ACT_PIPE;
if (skb->protocol == htons(ETH_P_IP)) {
- match_policy(skb, true, true);
+ match_policy(skb, true);
} else if (skb->protocol == htons(ETH_P_IPV6)) {
- match_policy(skb, false, true);
+ match_policy(skb, false);
}
// Always return TC_ACT_PIPE