rename try_make_readable() to try_make_writable()
In practice this function makes things readable and writable, so use a less confusing name. Test: TreeHugger, 'git grep try_make_readable' comes up empty Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I32faad148cc5714cf0ec7246620376ed4dd3d6d2
This commit is contained in:
@@ -65,8 +65,9 @@ static inline __always_inline __unused bool is_received_skb(struct __sk_buff* sk
|
||||
skb->pkt_type == PACKET_MULTICAST;
|
||||
}
|
||||
|
||||
// try to make the first 'len' header bytes readable via direct packet access
|
||||
static inline __always_inline void try_make_readable(struct __sk_buff* skb, int len) {
|
||||
// try to make the first 'len' header bytes readable/writable via direct packet access
|
||||
// (note: AFAIK there is no way to ask for only direct packet read without also getting write)
|
||||
static inline __always_inline void try_make_writable(struct __sk_buff* skb, int len) {
|
||||
if (len > skb->len) len = skb->len;
|
||||
if (skb->data_end - skb->data < len) bpf_skb_pull_data(skb, len);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ static inline __always_inline int nat64(struct __sk_buff* skb, bool is_ethernet)
|
||||
// Not clear if this is actually necessary considering we use DPA (Direct Packet Access),
|
||||
// but we need to make sure we can read the IPv6 header reliably so that we can set
|
||||
// skb->mark = 0xDeadC1a7 for packets we fail to offload.
|
||||
try_make_readable(skb, l2_header_size + sizeof(struct ipv6hdr));
|
||||
try_make_writable(skb, l2_header_size + sizeof(struct ipv6hdr));
|
||||
|
||||
void* data = (void*)(long)skb->data;
|
||||
const void* data_end = (void*)(long)skb->data_end;
|
||||
@@ -224,7 +224,7 @@ DEFINE_BPF_PROG("schedcls/egress4/clat_rawip", AID_ROOT, AID_SYSTEM, sched_cls_e
|
||||
if (skb->protocol != htons(ETH_P_IP)) return TC_ACT_PIPE;
|
||||
|
||||
// Possibly not needed, but for consistency with nat64 up above
|
||||
try_make_readable(skb, sizeof(struct iphdr));
|
||||
try_make_writable(skb, sizeof(struct iphdr));
|
||||
|
||||
void* data = (void*)(long)skb->data;
|
||||
const void* data_end = (void*)(long)skb->data_end;
|
||||
|
||||
@@ -122,7 +122,7 @@ static inline __always_inline int do_forward6(struct __sk_buff* skb, const bool
|
||||
// not trigger and thus we need to manually make sure we can read packet headers via DPA.
|
||||
// Note: this is a blind best effort pull, which may fail or pull less - this doesn't matter.
|
||||
// It has to be done early cause it will invalidate any skb->data/data_end derived pointers.
|
||||
try_make_readable(skb, l2_header_size + IP6_HLEN + TCP_HLEN);
|
||||
try_make_writable(skb, l2_header_size + IP6_HLEN + TCP_HLEN);
|
||||
|
||||
void* data = (void*)(long)skb->data;
|
||||
const void* data_end = (void*)(long)skb->data_end;
|
||||
@@ -369,7 +369,7 @@ static inline __always_inline int do_forward4(struct __sk_buff* skb, const bool
|
||||
// not trigger and thus we need to manually make sure we can read packet headers via DPA.
|
||||
// Note: this is a blind best effort pull, which may fail or pull less - this doesn't matter.
|
||||
// It has to be done early cause it will invalidate any skb->data/data_end derived pointers.
|
||||
try_make_readable(skb, l2_header_size + IP4_HLEN + TCP_HLEN);
|
||||
try_make_writable(skb, l2_header_size + IP4_HLEN + TCP_HLEN);
|
||||
|
||||
void* data = (void*)(long)skb->data;
|
||||
const void* data_end = (void*)(long)skb->data_end;
|
||||
|
||||
Reference in New Issue
Block a user