Skip to content

Commit 8c144dd

Browse files
committed
packet04-tailgrow: cleanup and describe demo use-case
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
1 parent a617989 commit 8c144dd

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

packet04-tailgrow/xdp_prog_kern.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,16 @@ int xdp_tailgrow3(struct xdp_md *ctx)
163163
return xdp_stats_record_action(ctx, XDP_PASS);
164164
}
165165

166-
167-
#define compiler_barrier() __asm__ __volatile__("": : :"memory")
168-
169166
SEC("xdp_tailgrow_parse")
170167
int grow_parse(struct xdp_md *ctx)
171168
{
172-
void *data_end; // = (void *)(long)ctx->data_end;
173-
void *data; // = (void *)(long)ctx->data;
174-
169+
void *data_end;
170+
void *data;
175171
int action = XDP_PASS;
176172
int eth_type, ip_type;
177-
struct ethhdr *eth;
178-
struct iphdr *iphdr;
179173
struct hdr_cursor nh;
180-
174+
struct iphdr *iphdr;
175+
struct ethhdr *eth;
181176
__u16 ip_tot_len;
182177

183178
struct my_timestamp *ts;
@@ -187,7 +182,6 @@ int grow_parse(struct xdp_md *ctx)
187182
bpf_xdp_adjust_tail(ctx, offset);
188183
data_end = (void *)(long)ctx->data_end;
189184
data = (void *)(long)ctx->data;
190-
// compiler_barrier();
191185

192186
/* These keep track of the next header type and iterator pointer */
193187
nh.pos = data;
@@ -205,6 +199,10 @@ int grow_parse(struct xdp_md *ctx)
205199
goto out;
206200
}
207201

202+
/* Demo use-case: Add timestamp in extended tailroom to ICMP packets,
203+
* before sending to network-stack via XDP_PASS. This can be
204+
* captured via tcpdump, and provide earlier (XDP layer) timestamp.
205+
*/
208206
if (ip_type == IPPROTO_ICMP) {
209207

210208
/* Packet size in bytes, including IP header and data */

0 commit comments

Comments
 (0)