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:
Simon Sundberg
2021-02-16 13:16:12 +01:00
parent 7fe1d282ae
commit a2c6b0618b
3 changed files with 14 additions and 14 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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;