sk = bpf_map_lookup_elem(&server_map, &zero); if (!sk) return TC_ACT_SHOT;
if (sk->state != BPF_TCP_LISTEN) {
bpf_sk_release(sk); return TC_ACT_SHOT;
}
assign:
ret = bpf_sk_assign(skb, sk, 0);
bpf_sk_release(sk); return ret;
}
SEC("tc") int bpf_sk_assign_test(struct __sk_buff *skb)
{ struct bpf_sock_tuple *tuple; bool ipv4 = false; bool tcp = false; int ret = 0;
tuple = get_tuple(skb, &ipv4, &tcp); if (!tuple) return TC_ACT_SHOT;
/* Note that the verifier socket return type for bpf_skc_lookup_tcp() * differs from bpf_sk_lookup_udp(), so even though the C-level type is * the same here, if we try to share the implementations they will * fail to verify because we're crossing pointer types.
*/ if (tcp)
ret = handle_tcp(skb, tuple, ipv4); else
ret = handle_udp(skb, tuple, ipv4);
return ret == 0 ? TC_ACT_OK : TC_ACT_SHOT;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.19 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.