+#define unlikely(a) __builtin_expect(a, 0)
+#define likely(a) __builtin_expect(a, 1)
+
+static const uint32_t PKT_LEN_DROP = 0;
+static const uint32_t VLAN_DROP = 1;
+static const uint32_t IHL_DROP = 2;
+static const uint32_t V6FRAG_DROP = 3;
+#define STATIC_RULE_CNT 4
+
+#define DO_RETURN(reason, ret) {\
+ if (ret == XDP_DROP) { INCREMENT_MATCH(reason); } \
+ return ret; \
+ }
+
+// It seems (based on drop counts) that data_end points to the last byte, not one-past-the-end.
+// This feels strange, but some documentation suggests > here as well, so we stick with that.
+#define CHECK_LEN(start, struc) \
+ if (unlikely((void*)(start) + sizeof(struct struc) > data_end)) DO_RETURN(PKT_LEN_DROP, XDP_DROP);
+