diff --git a/ebpf/kernel/llb_kern_ct.c b/ebpf/kernel/llb_kern_ct.c index 77619843..ed4c501f 100644 --- a/ebpf/kernel/llb_kern_ct.c +++ b/ebpf/kernel/llb_kern_ct.c @@ -265,7 +265,12 @@ dp_ct_tcp_sm(void *ctx, struct xfi *xf, break; case CT_TCP_SS: if (dir != CT_DIR_OUT) { - nstate = CT_TCP_ERR; + if ((tcp_flags & LLB_TCP_SYN) == LLB_TCP_SYN) { + td->seq = seq; + nstate = CT_TCP_SS; + } else { + nstate = CT_TCP_ERR; + } goto end; } @@ -289,6 +294,12 @@ dp_ct_tcp_sm(void *ctx, struct xfi *xf, nstate = CT_TCP_ERR; goto end; } + + if ((tcp_flags & LLB_TCP_SYN) == LLB_TCP_SYN) { + td->seq = seq; + nstate = CT_TCP_SS; + goto end; + } if ((tcp_flags & LLB_TCP_ACK) != LLB_TCP_ACK) { nstate = CT_TCP_ERR; diff --git a/ebpf/kernel/llb_kern_devif.c b/ebpf/kernel/llb_kern_devif.c index 6c592522..defd92ee 100644 --- a/ebpf/kernel/llb_kern_devif.c +++ b/ebpf/kernel/llb_kern_devif.c @@ -232,6 +232,26 @@ dp_unparse_packet_always(void *ctx, struct xfi *xf) } } + if (xf->tm.tun_decap) { + if (xf->tm.tun_type == LLB_TUN_GTP) { + LL_DBG_PRINTK("[DEPR] LL STRIP-GTP\n"); + if (dp_do_strip_gtp(ctx, xf, xf->pm.tun_off) != 0) { + return DP_DROP; + } + } + } else if (xf->tm.new_tunnel_id) { + if (xf->tm.tun_type == LLB_TUN_GTP) { + if (dp_do_ins_gtp(ctx, xf, + xf->tm.tun_rip, + xf->tm.tun_sip, + xf->tm.new_tunnel_id, + xf->qm.qfi, + 1)) { + return DP_DROP; + } + } + } + return 0; } @@ -244,27 +264,11 @@ dp_unparse_packet(void *ctx, struct xfi *xf) if (dp_do_strip_vxlan(ctx, xf, xf->pm.tun_off) != 0) { return DP_DROP; } - } else if (xf->tm.tun_type == LLB_TUN_GTP) { - LL_DBG_PRINTK("[DEPR] LL STRIP-GTP\n"); - if (dp_do_strip_gtp(ctx, xf, xf->pm.tun_off) != 0) { - return DP_DROP; - } } - } - - if (xf->tm.new_tunnel_id) { + } else if (xf->tm.new_tunnel_id) { LL_DBG_PRINTK("[DEPR] LL_NEW-TUN 0x%x\n", bpf_ntohl(xf->tm.new_tunnel_id)); - if (xf->tm.tun_type == LLB_TUN_GTP) { - if (dp_do_ins_gtp(ctx, xf, - xf->tm.tun_rip, - xf->tm.tun_sip, - xf->tm.new_tunnel_id, - xf->qm.qfi, - 1)) { - return DP_DROP; - } - } else if (xf->tm.tun_type == LLB_TUN_VXLAN) { + if (xf->tm.tun_type == LLB_TUN_VXLAN) { if (dp_do_ins_vxlan(ctx, xf, xf->tm.tun_rip, xf->tm.tun_sip, diff --git a/ebpf/kernel/llb_kern_l2fwd.c b/ebpf/kernel/llb_kern_l2fwd.c index 25ee2c26..bdc678ff 100644 --- a/ebpf/kernel/llb_kern_l2fwd.c +++ b/ebpf/kernel/llb_kern_l2fwd.c @@ -10,6 +10,10 @@ dp_do_smac_lkup(void *ctx, struct xfi *xf, void *fc) struct dp_smac_key key; struct dp_smac_tact *sma; + if (xf->l2m.vlan[0] == 0) { + return 0; + } + memcpy(key.smac, xf->l2m.dl_src, 6); key.bd = xf->pm.bd; @@ -282,7 +286,7 @@ dp_do_nh_lkup(void *ctx, struct xfi *xf, void *fa_) nha = bpf_map_lookup_elem(&nh_map, &key); if (!nha) { /* No NH - Drop */ - LLBS_PPLN_DROP(xf); + LLBS_PPLN_TRAP(xf) return 0; }