/* Redirecting packets based on the destination MAC address */
idx = ((unsignedint)(eth->h_dest[5])) / 2; if (idx > MAX_SOCKETS) return XDP_DROP;
return bpf_redirect_map(&xsk, idx, XDP_DROP);
}
SEC("xdp.frags") int xsk_xdp_adjust_tail(struct xdp_md *xdp)
{
__u32 buff_len, curr_buff_len; int ret;
buff_len = bpf_xdp_get_buff_len(xdp); if (buff_len == 0) return XDP_DROP;
ret = bpf_xdp_adjust_tail(xdp, adjust_value); if (ret < 0) { /* Handle unsupported cases */ if (ret == -EOPNOTSUPP) { /* Set adjust_value to -EOPNOTSUPP to indicate to userspace that this case * is unsupported
*/
adjust_value = -EOPNOTSUPP; return bpf_redirect_map(&xsk, 0, XDP_DROP);
}
len = curr_buff_len - PKT_HDR_ALIGN;
words_to_end = len / sizeof(*pkt_data) - 1;
seq_num = words_to_end;
/* Convert sequence number to network byte order. Store this in the last 4 bytes of * the packet. Use 'adjust_value' to determine the position at the end of the * packet for storing the sequence number.
*/
seq_num = __constant_htonl(words_to_end);
bpf_xdp_store_bytes(xdp, curr_buff_len - sizeof(seq_num), &seq_num, sizeof(seq_num));
}
return bpf_redirect_map(&xsk, 0, XDP_DROP);
}
char _license[] SEC("license") = "GPL";
Messung V0.5
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.