From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.bufferbloat.net (Postfix) with ESMTPS id 4D9763B2A4 for ; Wed, 29 Jun 2022 11:18:17 -0400 (EDT) Received: by mail-ej1-x630.google.com with SMTP id mf9so33367953ejb.0 for ; Wed, 29 Jun 2022 08:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=lsyN3nAGhlpLic0VSOGDOj2/TC4feLVQE4BHdNdf7PI=; b=ow4g6SCJuBU5He6x0hVEaobJWp4ZyvrANwEvqtpyld7FIRw0AOFtP8Pr102Fj7iFgv VZBJOBXktLzVcc7FfPyYQVI53K8zI2ODmUtJH5s/+PLSgio+ltJ8u9cXA7pjzDzP7oJg qsZYdoWlBPzf4xzvR3Uu4s2dmG1MSZkELilIEmAQdKVt48zaxP+ixOVQyzM5gqPUY75c nXf0vcnJ1gIpaaTthnKqkRzIMdWozcZny7xuo5tjX3RRyuhzf4kMl9N3DEwFX9KaJLcZ wrY0z5NUmszFi1eoFR1tefF69hw8blgLavR2NR6hdp2WfofVrSjE/aAvwv5gITb5iJTO gHsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=lsyN3nAGhlpLic0VSOGDOj2/TC4feLVQE4BHdNdf7PI=; b=HJAwqO4Oi81hXnYyxCn3M3HGiuPWdWH0uBtODSFQD03YijtKFEmoxyrccG6NVujFfU WybjwbrARlSKuE4E+inJtkOScNaoySpriEhleUvG5e28hzrTnpFHkjpnNcUJXuotK1nA bAtnOWSdPtvgptrNINRS/voH/DaKjFCD49+lRHblPZZ9PPNdTY+8kjo443+dzM1MFfPt FcNWaop9qp64bwB0lWunNYJTh5Dxwc0c3pKZSiThZf735073NKvY3nDG6HIiJs4bpEfY oXZQYJM0mmUqoDXli5/ZmyNzv6hKam8eioUFH1afVpuybqtJ0yywkpo96xrzJ9YAZ4NE cGbg== X-Gm-Message-State: AJIora8kDaR6BewN62navhPMApFRl6t1pi8hrkfBWLKyBs/gq5cpt1TM S/YUtl+DF7xpVs/jsMgqpvb38865HZLvNLR8PTRBBUe5 X-Google-Smtp-Source: AGRyM1sawH6K+MHiaQHYaa/Zvrf/PVuhUCDDR17SKZIBL+Ny6Q4tauu/7dJUil3WbpgffhG0FZ2JaRJGMTkTd9G8S0E= X-Received: by 2002:a17:906:4fc6:b0:722:e739:53cb with SMTP id i6-20020a1709064fc600b00722e73953cbmr3853091ejw.128.1656515895917; Wed, 29 Jun 2022 08:18:15 -0700 (PDT) MIME-Version: 1.0 References: <20220629143859.209028-1-marcin.szycik@linux.intel.com> <20220629143859.209028-2-marcin.szycik@linux.intel.com> In-Reply-To: <20220629143859.209028-2-marcin.szycik@linux.intel.com> From: Dave Taht Date: Wed, 29 Jun 2022 08:18:02 -0700 Message-ID: To: Cake List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: [Cake] Fwd: [RFC PATCH net-next v3 1/4] flow_dissector: Add PPPoE dissectors X-BeenThere: cake@lists.bufferbloat.net X-Mailman-Version: 2.1.20 Precedence: list List-Id: Cake - FQ_codel the next generation List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2022 15:18:17 -0000 ppp makes my head hurt. so does mpls. when do we need to dissect it? ---------- Forwarded message --------- From: Marcin Szycik Date: Wed, Jun 29, 2022 at 8:01 AM Subject: [RFC PATCH net-next v3 1/4] flow_dissector: Add PPPoE dissectors To: Cc: , , , , , , , , , , , , , , , , , , , , , , , , From: Wojciech Drewek Allow to dissect PPPoE specific fields which are: - session ID (16 bits) - ppp protocol (16 bits) The goal is to make the following TC command possible: # tc filter add dev ens6f0 ingress prio 1 protocol ppp_ses \ flower \ pppoe_sid 12 \ ppp_proto ip \ action drop Note that only PPPoE Session is supported. Signed-off-by: Wojciech Drewek --- v3: revert byte order changes in is_ppp_proto_supported from previous version, add kernel-doc for is_ppp_proto_supported v2: use ntohs instead of htons in is_ppp_proto_supported include/net/flow_dissector.h | 11 ++++++++ net/core/flow_dissector.c | 55 ++++++++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/include/net/flow_dissector.h b/include/net/flow_dissector.h index a4c6057c7097..8ff40c7c3f1c 100644 --- a/include/net/flow_dissector.h +++ b/include/net/flow_dissector.h @@ -261,6 +261,16 @@ struct flow_dissector_key_num_of_vlans { u8 num_of_vlans; }; +/** + * struct flow_dissector_key_pppoe: + * @session_id: pppoe session id + * @ppp_proto: ppp protocol + */ +struct flow_dissector_key_pppoe { + u16 session_id; + __be16 ppp_proto; +}; + enum flow_dissector_key_id { FLOW_DISSECTOR_KEY_CONTROL, /* struct flow_dissector_key_control */ FLOW_DISSECTOR_KEY_BASIC, /* struct flow_dissector_key_basic */ @@ -291,6 +301,7 @@ enum flow_dissector_key_id { FLOW_DISSECTOR_KEY_CT, /* struct flow_dissector_key_ct */ FLOW_DISSECTOR_KEY_HASH, /* struct flow_dissector_key_hash */ FLOW_DISSECTOR_KEY_NUM_OF_VLANS, /* struct flow_dissector_key_num_of_vlans */ + FLOW_DISSECTOR_KEY_PPPOE, /* struct flow_dissector_key_pppoe */ FLOW_DISSECTOR_KEY_MAX, }; diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 6aee04f75e3e..42393af477a2 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -895,6 +895,39 @@ bool bpf_flow_dissect(struct bpf_prog *prog, struct bpf_flow_dissector *ctx, return result =3D=3D BPF_OK; } +/** + * is_ppp_proto_supported - checks if inner PPP protocol should be dissect= ed + * @proto: protocol type (PPP proto field) + */ +static bool is_ppp_proto_supported(__be16 proto) +{ + switch (proto) { + case htons(PPP_AT): + case htons(PPP_IPX): + case htons(PPP_VJC_COMP): + case htons(PPP_VJC_UNCOMP): + case htons(PPP_MP): + case htons(PPP_COMPFRAG): + case htons(PPP_COMP): + case htons(PPP_MPLS_UC): + case htons(PPP_MPLS_MC): + case htons(PPP_IPCP): + case htons(PPP_ATCP): + case htons(PPP_IPXCP): + case htons(PPP_IPV6CP): + case htons(PPP_CCPFRAG): + case htons(PPP_MPLSCP): + case htons(PPP_LCP): + case htons(PPP_PAP): + case htons(PPP_LQR): + case htons(PPP_CHAP): + case htons(PPP_CBCP): + return true; + default: + return false; + } +} + /** * __skb_flow_dissect - extract the flow_keys struct and return it * @net: associated network namespace, derived from @skb if NULL @@ -1221,19 +1254,29 @@ bool __skb_flow_dissect(const struct net *net, } nhoff +=3D PPPOE_SES_HLEN; - switch (hdr->proto) { - case htons(PPP_IP): + if (hdr->proto =3D=3D htons(PPP_IP)) { proto =3D htons(ETH_P_IP); fdret =3D FLOW_DISSECT_RET_PROTO_AGAIN; - break; - case htons(PPP_IPV6): + } else if (hdr->proto =3D=3D htons(PPP_IPV6)) { proto =3D htons(ETH_P_IPV6); fdret =3D FLOW_DISSECT_RET_PROTO_AGAIN; - break; - default: + } else if (is_ppp_proto_supported(hdr->proto)) { + fdret =3D FLOW_DISSECT_RET_OUT_GOOD; + } else { fdret =3D FLOW_DISSECT_RET_OUT_BAD; break; } + + if (dissector_uses_key(flow_dissector, + FLOW_DISSECTOR_KEY_PPPOE)) { + struct flow_dissector_key_pppoe *key_pppoe; + + key_pppoe =3D skb_flow_dissector_target(flow_dissec= tor, + FLOW_DISSECTOR_KEY_PPPOE, + target_contai= ner); + key_pppoe->session_id =3D ntohs(hdr->hdr.sid); + key_pppoe->ppp_proto =3D hdr->proto; + } break; } case htons(ETH_P_TIPC): { -- 2.35.1 --=20 FQ World Domination pending: https://blog.cerowrt.org/post/state_of_fq_code= l/ Dave T=C3=A4ht CEO, TekLibre, LLC