static __always_inline int tc_redir(struct __sk_buff *skb)
{ struct bpf_fib_lookup fib_params = { .ifindex = skb->ingress_ifindex };
__u8 zero[ETH_ALEN * 2]; int ret = -1;
switch (skb->protocol) { case __bpf_constant_htons(ETH_P_IP):
ret = fill_fib_params_v4(skb, &fib_params); break; case __bpf_constant_htons(ETH_P_IPV6):
ret = fill_fib_params_v6(skb, &fib_params); break;
}
if (ret) return TC_ACT_OK;
ret = bpf_fib_lookup(skb, &fib_params, sizeof(fib_params), 0); if (ret == BPF_FIB_LKUP_RET_NOT_FWDED || ret < 0) return TC_ACT_OK;
/* these are identical, but keep them separate for compatibility with the * section names expected by test_tc_redirect.sh
*/
SEC("tc") int tc_dst(struct __sk_buff *skb)
{ return tc_redir(skb);
}
SEC("tc") int tc_src(struct __sk_buff *skb)
{ return tc_redir(skb);
}
char __license[] SEC("license") = "GPL";
Messung V0.5
¤ Dauer der Verarbeitung: 0.9 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.