flow_dissector: add mpls support (v2)
Add support for parsing MPLS flows to the flow dissector in preparation for adding MPLS match support to cls_flower. Signed-off-by: Benjamin LaHaise <benjamin.lahaise@netronome.com> Signed-off-by: Benjamin LaHaise <bcrl@kvack.org> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Simon Horman <simon.horman@netronome.com> Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: Cong Wang <xiyou.wangcong@gmail.com> Cc: Jiri Pirko <jiri@mellanox.com> Cc: Eric Dumazet <jhs@mojatatu.com> Cc: Hadar Hen Zion <hadarh@mellanox.com> Cc: Gao Feng <fgao@ikuai8.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3ec21b6580
commit
029c1ecbb2
|
@ -3,4 +3,9 @@
|
||||||
|
|
||||||
#include <uapi/linux/mpls.h>
|
#include <uapi/linux/mpls.h>
|
||||||
|
|
||||||
|
#define MPLS_TTL_MASK (MPLS_LS_TTL_MASK >> MPLS_LS_TTL_SHIFT)
|
||||||
|
#define MPLS_BOS_MASK (MPLS_LS_S_MASK >> MPLS_LS_S_SHIFT)
|
||||||
|
#define MPLS_TC_MASK (MPLS_LS_TC_MASK >> MPLS_LS_TC_SHIFT)
|
||||||
|
#define MPLS_LABEL_MASK (MPLS_LS_LABEL_MASK >> MPLS_LS_LABEL_SHIFT)
|
||||||
|
|
||||||
#endif /* _LINUX_MPLS_H */
|
#endif /* _LINUX_MPLS_H */
|
||||||
|
|
|
@ -41,6 +41,13 @@ struct flow_dissector_key_vlan {
|
||||||
u16 padding;
|
u16 padding;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct flow_dissector_key_mpls {
|
||||||
|
u32 mpls_ttl:8,
|
||||||
|
mpls_bos:1,
|
||||||
|
mpls_tc:3,
|
||||||
|
mpls_label:20;
|
||||||
|
};
|
||||||
|
|
||||||
struct flow_dissector_key_keyid {
|
struct flow_dissector_key_keyid {
|
||||||
__be32 keyid;
|
__be32 keyid;
|
||||||
};
|
};
|
||||||
|
@ -169,6 +176,7 @@ enum flow_dissector_key_id {
|
||||||
FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS, /* struct flow_dissector_key_ipv6_addrs */
|
FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS, /* struct flow_dissector_key_ipv6_addrs */
|
||||||
FLOW_DISSECTOR_KEY_ENC_CONTROL, /* struct flow_dissector_key_control */
|
FLOW_DISSECTOR_KEY_ENC_CONTROL, /* struct flow_dissector_key_control */
|
||||||
FLOW_DISSECTOR_KEY_ENC_PORTS, /* struct flow_dissector_key_ports */
|
FLOW_DISSECTOR_KEY_ENC_PORTS, /* struct flow_dissector_key_ports */
|
||||||
|
FLOW_DISSECTOR_KEY_MPLS, /* struct flow_dissector_key_mpls */
|
||||||
|
|
||||||
FLOW_DISSECTOR_KEY_MAX,
|
FLOW_DISSECTOR_KEY_MAX,
|
||||||
};
|
};
|
||||||
|
|
|
@ -126,9 +126,11 @@ __skb_flow_dissect_mpls(const struct sk_buff *skb,
|
||||||
{
|
{
|
||||||
struct flow_dissector_key_keyid *key_keyid;
|
struct flow_dissector_key_keyid *key_keyid;
|
||||||
struct mpls_label *hdr, _hdr[2];
|
struct mpls_label *hdr, _hdr[2];
|
||||||
|
u32 entry, label;
|
||||||
|
|
||||||
if (!dissector_uses_key(flow_dissector,
|
if (!dissector_uses_key(flow_dissector,
|
||||||
FLOW_DISSECTOR_KEY_MPLS_ENTROPY))
|
FLOW_DISSECTOR_KEY_MPLS_ENTROPY) &&
|
||||||
|
!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_MPLS))
|
||||||
return FLOW_DISSECT_RET_OUT_GOOD;
|
return FLOW_DISSECT_RET_OUT_GOOD;
|
||||||
|
|
||||||
hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data,
|
hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data,
|
||||||
|
@ -136,8 +138,25 @@ __skb_flow_dissect_mpls(const struct sk_buff *skb,
|
||||||
if (!hdr)
|
if (!hdr)
|
||||||
return FLOW_DISSECT_RET_OUT_BAD;
|
return FLOW_DISSECT_RET_OUT_BAD;
|
||||||
|
|
||||||
if ((ntohl(hdr[0].entry) & MPLS_LS_LABEL_MASK) >>
|
entry = ntohl(hdr[0].entry);
|
||||||
MPLS_LS_LABEL_SHIFT == MPLS_LABEL_ENTROPY) {
|
label = (entry & MPLS_LS_LABEL_MASK) >> MPLS_LS_LABEL_SHIFT;
|
||||||
|
|
||||||
|
if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_MPLS)) {
|
||||||
|
struct flow_dissector_key_mpls *key_mpls;
|
||||||
|
|
||||||
|
key_mpls = skb_flow_dissector_target(flow_dissector,
|
||||||
|
FLOW_DISSECTOR_KEY_MPLS,
|
||||||
|
target_container);
|
||||||
|
key_mpls->mpls_label = label;
|
||||||
|
key_mpls->mpls_ttl = (entry & MPLS_LS_TTL_MASK)
|
||||||
|
>> MPLS_LS_TTL_SHIFT;
|
||||||
|
key_mpls->mpls_tc = (entry & MPLS_LS_TC_MASK)
|
||||||
|
>> MPLS_LS_TC_SHIFT;
|
||||||
|
key_mpls->mpls_bos = (entry & MPLS_LS_S_MASK)
|
||||||
|
>> MPLS_LS_S_SHIFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (label == MPLS_LABEL_ENTROPY) {
|
||||||
key_keyid = skb_flow_dissector_target(flow_dissector,
|
key_keyid = skb_flow_dissector_target(flow_dissector,
|
||||||
FLOW_DISSECTOR_KEY_MPLS_ENTROPY,
|
FLOW_DISSECTOR_KEY_MPLS_ENTROPY,
|
||||||
target_container);
|
target_container);
|
||||||
|
|
Loading…
Reference in New Issue