mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
pping: Use designated initialization for parsing_context
Change how intitalization of pctx is done in tc and xdp programs. Also, len to pkt_len in parsing_context. Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
This commit is contained in:
@ -29,7 +29,7 @@ struct parsing_context {
|
||||
void *data; //Start of eth hdr
|
||||
void *data_end; //End of safe acessible area
|
||||
struct hdr_cursor nh; //Position to parse next
|
||||
__u32 len; //Full packet length (headers+data)
|
||||
__u32 pkt_len; //Full packet length (headers+data)
|
||||
};
|
||||
|
||||
/*
|
||||
@ -109,7 +109,7 @@ static int parse_tcp_identifier(struct parsing_context *ctx, bool is_egress,
|
||||
return -1;
|
||||
|
||||
// Do not timestamp pure ACKs
|
||||
if (is_egress && ctx->nh.pos - ctx->data >= ctx->len && !tcph->syn)
|
||||
if (is_egress && ctx->nh.pos - ctx->data >= ctx->pkt_len && !tcph->syn)
|
||||
return -1;
|
||||
|
||||
if (parse_tcp_ts(tcph, ctx->data_end, &tsval, &tsecr) < 0)
|
||||
|
@ -31,14 +31,14 @@ struct bpf_elf_map SEC("maps") ts_start = {
|
||||
SEC(TCBPF_PROG_SEC)
|
||||
int tc_bpf_prog_egress(struct __sk_buff *skb)
|
||||
{
|
||||
struct parsing_context pctx;
|
||||
struct packet_id p_id = { 0 };
|
||||
struct packet_timestamp p_ts = { 0 };
|
||||
|
||||
pctx.data = (void *)(long)skb->data;
|
||||
pctx.data_end = (void *)(long)skb->data_end;
|
||||
pctx.len = skb->len;
|
||||
pctx.nh.pos = pctx.data;
|
||||
struct parsing_context pctx = {
|
||||
.data = (void *)(long)skb->data,
|
||||
.data_end = (void *)(long)skb->data_end,
|
||||
.pkt_len = skb->len,
|
||||
.nh = { .pos = pctx.data },
|
||||
};
|
||||
|
||||
if (parse_packet_identifier(&pctx, true, &p_id) < 0)
|
||||
goto end;
|
||||
|
@ -25,15 +25,15 @@ struct {
|
||||
SEC(XDP_PROG_SEC)
|
||||
int xdp_prog_ingress(struct xdp_md *ctx)
|
||||
{
|
||||
struct parsing_context pctx;
|
||||
struct packet_id p_id = { 0 };
|
||||
struct packet_timestamp *p_ts;
|
||||
struct rtt_event event = { 0 };
|
||||
|
||||
pctx.data = (void *)(long)ctx->data;
|
||||
pctx.data_end = (void *)(long)ctx->data_end;
|
||||
pctx.len = pctx.data_end - pctx.data;
|
||||
pctx.nh.pos = pctx.data;
|
||||
struct parsing_context pctx = {
|
||||
.data = (void *)(long)ctx->data,
|
||||
.data_end = (void *)(long)ctx->data_end,
|
||||
.pkt_len = pctx.data_end - pctx.data,
|
||||
.nh = { .pos = pctx.data },
|
||||
};
|
||||
|
||||
if (parse_packet_identifier(&pctx, false, &p_id) < 0)
|
||||
goto end;
|
||||
|
Reference in New Issue
Block a user