diff options
| author | Benjamin LaHaise <benjamin.lahaise@netronome.com> | 2017-04-22 16:52:46 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2017-04-24 14:30:46 -0400 |
| commit | 029c1ecbb2429cf08c7bd2de81e929f81feea914 (patch) | |
| tree | 089ec0aa72c309409049b892c49cb867fb3732b1 /net/core | |
| parent | 3ec21b6580792c9890e265a46488afbe7dabc5d6 (diff) | |
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>
Diffstat (limited to 'net/core')
| -rw-r--r-- | net/core/flow_dissector.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index c9cf425303f8..28d94bce4df8 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c | |||
| @@ -126,9 +126,11 @@ __skb_flow_dissect_mpls(const struct sk_buff *skb, | |||
| 126 | { | 126 | { |
| 127 | struct flow_dissector_key_keyid *key_keyid; | 127 | struct flow_dissector_key_keyid *key_keyid; |
| 128 | struct mpls_label *hdr, _hdr[2]; | 128 | struct mpls_label *hdr, _hdr[2]; |
| 129 | u32 entry, label; | ||
| 129 | 130 | ||
| 130 | if (!dissector_uses_key(flow_dissector, | 131 | if (!dissector_uses_key(flow_dissector, |
| 131 | FLOW_DISSECTOR_KEY_MPLS_ENTROPY)) | 132 | FLOW_DISSECTOR_KEY_MPLS_ENTROPY) && |
| 133 | !dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_MPLS)) | ||
| 132 | return FLOW_DISSECT_RET_OUT_GOOD; | 134 | return FLOW_DISSECT_RET_OUT_GOOD; |
| 133 | 135 | ||
| 134 | hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data, | 136 | hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data, |
| @@ -136,8 +138,25 @@ __skb_flow_dissect_mpls(const struct sk_buff *skb, | |||
| 136 | if (!hdr) | 138 | if (!hdr) |
| 137 | return FLOW_DISSECT_RET_OUT_BAD; | 139 | return FLOW_DISSECT_RET_OUT_BAD; |
| 138 | 140 | ||
| 139 | if ((ntohl(hdr[0].entry) & MPLS_LS_LABEL_MASK) >> | 141 | entry = ntohl(hdr[0].entry); |
| 140 | MPLS_LS_LABEL_SHIFT == MPLS_LABEL_ENTROPY) { | 142 | label = (entry & MPLS_LS_LABEL_MASK) >> MPLS_LS_LABEL_SHIFT; |
| 143 | |||
| 144 | if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_MPLS)) { | ||
| 145 | struct flow_dissector_key_mpls *key_mpls; | ||
| 146 | |||
| 147 | key_mpls = skb_flow_dissector_target(flow_dissector, | ||
| 148 | FLOW_DISSECTOR_KEY_MPLS, | ||
| 149 | target_container); | ||
| 150 | key_mpls->mpls_label = label; | ||
| 151 | key_mpls->mpls_ttl = (entry & MPLS_LS_TTL_MASK) | ||
| 152 | >> MPLS_LS_TTL_SHIFT; | ||
| 153 | key_mpls->mpls_tc = (entry & MPLS_LS_TC_MASK) | ||
| 154 | >> MPLS_LS_TC_SHIFT; | ||
| 155 | key_mpls->mpls_bos = (entry & MPLS_LS_S_MASK) | ||
| 156 | >> MPLS_LS_S_SHIFT; | ||
| 157 | } | ||
| 158 | |||
| 159 | if (label == MPLS_LABEL_ENTROPY) { | ||
| 141 | key_keyid = skb_flow_dissector_target(flow_dissector, | 160 | key_keyid = skb_flow_dissector_target(flow_dissector, |
| 142 | FLOW_DISSECTOR_KEY_MPLS_ENTROPY, | 161 | FLOW_DISSECTOR_KEY_MPLS_ENTROPY, |
| 143 | target_container); | 162 | target_container); |
