~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/core/flow_dissector.c

Version: ~ [ linux-5.13-rc5 ] ~ [ linux-5.12.9 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.42 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.124 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.193 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.235 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.271 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.271 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 #include <linux/kernel.h>
  3 #include <linux/skbuff.h>
  4 #include <linux/export.h>
  5 #include <linux/ip.h>
  6 #include <linux/ipv6.h>
  7 #include <linux/if_vlan.h>
  8 #include <net/dsa.h>
  9 #include <net/dst_metadata.h>
 10 #include <net/ip.h>
 11 #include <net/ipv6.h>
 12 #include <net/gre.h>
 13 #include <net/pptp.h>
 14 #include <net/tipc.h>
 15 #include <linux/igmp.h>
 16 #include <linux/icmp.h>
 17 #include <linux/sctp.h>
 18 #include <linux/dccp.h>
 19 #include <linux/if_tunnel.h>
 20 #include <linux/if_pppox.h>
 21 #include <linux/ppp_defs.h>
 22 #include <linux/stddef.h>
 23 #include <linux/if_ether.h>
 24 #include <linux/mpls.h>
 25 #include <linux/tcp.h>
 26 #include <net/flow_dissector.h>
 27 #include <scsi/fc/fc_fcoe.h>
 28 #include <uapi/linux/batadv_packet.h>
 29 #include <linux/bpf.h>
 30 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
 31 #include <net/netfilter/nf_conntrack_core.h>
 32 #include <net/netfilter/nf_conntrack_labels.h>
 33 #endif
 34 
 35 static DEFINE_MUTEX(flow_dissector_mutex);
 36 
 37 static void dissector_set_key(struct flow_dissector *flow_dissector,
 38                               enum flow_dissector_key_id key_id)
 39 {
 40         flow_dissector->used_keys |= (1 << key_id);
 41 }
 42 
 43 void skb_flow_dissector_init(struct flow_dissector *flow_dissector,
 44                              const struct flow_dissector_key *key,
 45                              unsigned int key_count)
 46 {
 47         unsigned int i;
 48 
 49         memset(flow_dissector, 0, sizeof(*flow_dissector));
 50 
 51         for (i = 0; i < key_count; i++, key++) {
 52                 /* User should make sure that every key target offset is withing
 53                  * boundaries of unsigned short.
 54                  */
 55                 BUG_ON(key->offset > USHRT_MAX);
 56                 BUG_ON(dissector_uses_key(flow_dissector,
 57                                           key->key_id));
 58 
 59                 dissector_set_key(flow_dissector, key->key_id);
 60                 flow_dissector->offset[key->key_id] = key->offset;
 61         }
 62 
 63         /* Ensure that the dissector always includes control and basic key.
 64          * That way we are able to avoid handling lack of these in fast path.
 65          */
 66         BUG_ON(!dissector_uses_key(flow_dissector,
 67                                    FLOW_DISSECTOR_KEY_CONTROL));
 68         BUG_ON(!dissector_uses_key(flow_dissector,
 69                                    FLOW_DISSECTOR_KEY_BASIC));
 70 }
 71 EXPORT_SYMBOL(skb_flow_dissector_init);
 72 
 73 int skb_flow_dissector_prog_query(const union bpf_attr *attr,
 74                                   union bpf_attr __user *uattr)
 75 {
 76         __u32 __user *prog_ids = u64_to_user_ptr(attr->query.prog_ids);
 77         u32 prog_id, prog_cnt = 0, flags = 0;
 78         struct bpf_prog *attached;
 79         struct net *net;
 80 
 81         if (attr->query.query_flags)
 82                 return -EINVAL;
 83 
 84         net = get_net_ns_by_fd(attr->query.target_fd);
 85         if (IS_ERR(net))
 86                 return PTR_ERR(net);
 87 
 88         rcu_read_lock();
 89         attached = rcu_dereference(net->flow_dissector_prog);
 90         if (attached) {
 91                 prog_cnt = 1;
 92                 prog_id = attached->aux->id;
 93         }
 94         rcu_read_unlock();
 95 
 96         put_net(net);
 97 
 98         if (copy_to_user(&uattr->query.attach_flags, &flags, sizeof(flags)))
 99                 return -EFAULT;
100         if (copy_to_user(&uattr->query.prog_cnt, &prog_cnt, sizeof(prog_cnt)))
101                 return -EFAULT;
102 
103         if (!attr->query.prog_cnt || !prog_ids || !prog_cnt)
104                 return 0;
105 
106         if (copy_to_user(prog_ids, &prog_id, sizeof(u32)))
107                 return -EFAULT;
108 
109         return 0;
110 }
111 
112 int skb_flow_dissector_bpf_prog_attach(const union bpf_attr *attr,
113                                        struct bpf_prog *prog)
114 {
115         struct bpf_prog *attached;
116         struct net *net;
117 
118         net = current->nsproxy->net_ns;
119         mutex_lock(&flow_dissector_mutex);
120         attached = rcu_dereference_protected(net->flow_dissector_prog,
121                                              lockdep_is_held(&flow_dissector_mutex));
122         if (attached) {
123                 /* Only one BPF program can be attached at a time */
124                 mutex_unlock(&flow_dissector_mutex);
125                 return -EEXIST;
126         }
127         rcu_assign_pointer(net->flow_dissector_prog, prog);
128         mutex_unlock(&flow_dissector_mutex);
129         return 0;
130 }
131 
132 int skb_flow_dissector_bpf_prog_detach(const union bpf_attr *attr)
133 {
134         struct bpf_prog *attached;
135         struct net *net;
136 
137         net = current->nsproxy->net_ns;
138         mutex_lock(&flow_dissector_mutex);
139         attached = rcu_dereference_protected(net->flow_dissector_prog,
140                                              lockdep_is_held(&flow_dissector_mutex));
141         if (!attached) {
142                 mutex_unlock(&flow_dissector_mutex);
143                 return -ENOENT;
144         }
145         RCU_INIT_POINTER(net->flow_dissector_prog, NULL);
146         bpf_prog_put(attached);
147         mutex_unlock(&flow_dissector_mutex);
148         return 0;
149 }
150 /**
151  * skb_flow_get_be16 - extract be16 entity
152  * @skb: sk_buff to extract from
153  * @poff: offset to extract at
154  * @data: raw buffer pointer to the packet
155  * @hlen: packet header length
156  *
157  * The function will try to retrieve a be32 entity at
158  * offset poff
159  */
160 static __be16 skb_flow_get_be16(const struct sk_buff *skb, int poff,
161                                 void *data, int hlen)
162 {
163         __be16 *u, _u;
164 
165         u = __skb_header_pointer(skb, poff, sizeof(_u), data, hlen, &_u);
166         if (u)
167                 return *u;
168 
169         return 0;
170 }
171 
172 /**
173  * __skb_flow_get_ports - extract the upper layer ports and return them
174  * @skb: sk_buff to extract the ports from
175  * @thoff: transport header offset
176  * @ip_proto: protocol for which to get port offset
177  * @data: raw buffer pointer to the packet, if NULL use skb->data
178  * @hlen: packet header length, if @data is NULL use skb_headlen(skb)
179  *
180  * The function will try to retrieve the ports at offset thoff + poff where poff
181  * is the protocol port offset returned from proto_ports_offset
182  */
183 __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
184                             void *data, int hlen)
185 {
186         int poff = proto_ports_offset(ip_proto);
187 
188         if (!data) {
189                 data = skb->data;
190                 hlen = skb_headlen(skb);
191         }
192 
193         if (poff >= 0) {
194                 __be32 *ports, _ports;
195 
196                 ports = __skb_header_pointer(skb, thoff + poff,
197                                              sizeof(_ports), data, hlen, &_ports);
198                 if (ports)
199                         return *ports;
200         }
201 
202         return 0;
203 }
204 EXPORT_SYMBOL(__skb_flow_get_ports);
205 
206 void skb_flow_dissect_meta(const struct sk_buff *skb,
207                            struct flow_dissector *flow_dissector,
208                            void *target_container)
209 {
210         struct flow_dissector_key_meta *meta;
211 
212         if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_META))
213                 return;
214 
215         meta = skb_flow_dissector_target(flow_dissector,
216                                          FLOW_DISSECTOR_KEY_META,
217                                          target_container);
218         meta->ingress_ifindex = skb->skb_iif;
219 }
220 EXPORT_SYMBOL(skb_flow_dissect_meta);
221 
222 static void
223 skb_flow_dissect_set_enc_addr_type(enum flow_dissector_key_id type,
224                                    struct flow_dissector *flow_dissector,
225                                    void *target_container)
226 {
227         struct flow_dissector_key_control *ctrl;
228 
229         if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_CONTROL))
230                 return;
231 
232         ctrl = skb_flow_dissector_target(flow_dissector,
233                                          FLOW_DISSECTOR_KEY_ENC_CONTROL,
234                                          target_container);
235         ctrl->addr_type = type;
236 }
237 
238 void
239 skb_flow_dissect_ct(const struct sk_buff *skb,
240                     struct flow_dissector *flow_dissector,
241                     void *target_container,
242                     u16 *ctinfo_map,
243                     size_t mapsize)
244 {
245 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
246         struct flow_dissector_key_ct *key;
247         enum ip_conntrack_info ctinfo;
248         struct nf_conn_labels *cl;
249         struct nf_conn *ct;
250 
251         if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_CT))
252                 return;
253 
254         ct = nf_ct_get(skb, &ctinfo);
255         if (!ct)
256                 return;
257 
258         key = skb_flow_dissector_target(flow_dissector,
259                                         FLOW_DISSECTOR_KEY_CT,
260                                         target_container);
261 
262         if (ctinfo < mapsize)
263                 key->ct_state = ctinfo_map[ctinfo];
264 #if IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES)
265         key->ct_zone = ct->zone.id;
266 #endif
267 #if IS_ENABLED(CONFIG_NF_CONNTRACK_MARK)
268         key->ct_mark = ct->mark;
269 #endif
270 
271         cl = nf_ct_labels_find(ct);
272         if (cl)
273                 memcpy(key->ct_labels, cl->bits, sizeof(key->ct_labels));
274 #endif /* CONFIG_NF_CONNTRACK */
275 }
276 EXPORT_SYMBOL(skb_flow_dissect_ct);
277 
278 void
279 skb_flow_dissect_tunnel_info(const struct sk_buff *skb,
280                              struct flow_dissector *flow_dissector,
281                              void *target_container)
282 {
283         struct ip_tunnel_info *info;
284         struct ip_tunnel_key *key;
285 
286         /* A quick check to see if there might be something to do. */
287         if (!dissector_uses_key(flow_dissector,
288                                 FLOW_DISSECTOR_KEY_ENC_KEYID) &&
289             !dissector_uses_key(flow_dissector,
290                                 FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS) &&
291             !dissector_uses_key(flow_dissector,
292                                 FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS) &&
293             !dissector_uses_key(flow_dissector,
294                                 FLOW_DISSECTOR_KEY_ENC_CONTROL) &&
295             !dissector_uses_key(flow_dissector,
296                                 FLOW_DISSECTOR_KEY_ENC_PORTS) &&
297             !dissector_uses_key(flow_dissector,
298                                 FLOW_DISSECTOR_KEY_ENC_IP) &&
299             !dissector_uses_key(flow_dissector,
300                                 FLOW_DISSECTOR_KEY_ENC_OPTS))
301                 return;
302 
303         info = skb_tunnel_info(skb);
304         if (!info)
305                 return;
306 
307         key = &info->key;
308 
309         switch (ip_tunnel_info_af(info)) {
310         case AF_INET:
311                 skb_flow_dissect_set_enc_addr_type(FLOW_DISSECTOR_KEY_IPV4_ADDRS,
312                                                    flow_dissector,
313                                                    target_container);
314                 if (dissector_uses_key(flow_dissector,
315                                        FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS)) {
316                         struct flow_dissector_key_ipv4_addrs *ipv4;
317 
318                         ipv4 = skb_flow_dissector_target(flow_dissector,
319                                                          FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS,
320                                                          target_container);
321                         ipv4->src = key->u.ipv4.src;
322                         ipv4->dst = key->u.ipv4.dst;
323                 }
324                 break;
325         case AF_INET6:
326                 skb_flow_dissect_set_enc_addr_type(FLOW_DISSECTOR_KEY_IPV6_ADDRS,
327                                                    flow_dissector,
328                                                    target_container);
329                 if (dissector_uses_key(flow_dissector,
330                                        FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS)) {
331                         struct flow_dissector_key_ipv6_addrs *ipv6;
332 
333                         ipv6 = skb_flow_dissector_target(flow_dissector,
334                                                          FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS,
335                                                          target_container);
336                         ipv6->src = key->u.ipv6.src;
337                         ipv6->dst = key->u.ipv6.dst;
338                 }
339                 break;
340         }
341 
342         if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_KEYID)) {
343                 struct flow_dissector_key_keyid *keyid;
344 
345                 keyid = skb_flow_dissector_target(flow_dissector,
346                                                   FLOW_DISSECTOR_KEY_ENC_KEYID,
347                                                   target_container);
348                 keyid->keyid = tunnel_id_to_key32(key->tun_id);
349         }
350 
351         if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_PORTS)) {
352                 struct flow_dissector_key_ports *tp;
353 
354                 tp = skb_flow_dissector_target(flow_dissector,
355                                                FLOW_DISSECTOR_KEY_ENC_PORTS,
356                                                target_container);
357                 tp->src = key->tp_src;
358                 tp->dst = key->tp_dst;
359         }
360 
361         if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_IP)) {
362                 struct flow_dissector_key_ip *ip;
363 
364                 ip = skb_flow_dissector_target(flow_dissector,
365                                                FLOW_DISSECTOR_KEY_ENC_IP,
366                                                target_container);
367                 ip->tos = key->tos;
368                 ip->ttl = key->ttl;
369         }
370 
371         if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_OPTS)) {
372                 struct flow_dissector_key_enc_opts *enc_opt;
373 
374                 enc_opt = skb_flow_dissector_target(flow_dissector,
375                                                     FLOW_DISSECTOR_KEY_ENC_OPTS,
376                                                     target_container);
377 
378                 if (info->options_len) {
379                         enc_opt->len = info->options_len;
380                         ip_tunnel_info_opts_get(enc_opt->data, info);
381                         enc_opt->dst_opt_type = info->key.tun_flags &
382                                                 TUNNEL_OPTIONS_PRESENT;
383                 }
384         }
385 }
386 EXPORT_SYMBOL(skb_flow_dissect_tunnel_info);
387 
388 static enum flow_dissect_ret
389 __skb_flow_dissect_mpls(const struct sk_buff *skb,
390                         struct flow_dissector *flow_dissector,
391                         void *target_container, void *data, int nhoff, int hlen)
392 {
393         struct flow_dissector_key_keyid *key_keyid;
394         struct mpls_label *hdr, _hdr[2];
395         u32 entry, label;
396 
397         if (!dissector_uses_key(flow_dissector,
398                                 FLOW_DISSECTOR_KEY_MPLS_ENTROPY) &&
399             !dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_MPLS))
400                 return FLOW_DISSECT_RET_OUT_GOOD;
401 
402         hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data,
403                                    hlen, &_hdr);
404         if (!hdr)
405                 return FLOW_DISSECT_RET_OUT_BAD;
406 
407         entry = ntohl(hdr[0].entry);
408         label = (entry & MPLS_LS_LABEL_MASK) >> MPLS_LS_LABEL_SHIFT;
409 
410         if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_MPLS)) {
411                 struct flow_dissector_key_mpls *key_mpls;
412 
413                 key_mpls = skb_flow_dissector_target(flow_dissector,
414                                                      FLOW_DISSECTOR_KEY_MPLS,
415                                                      target_container);
416                 key_mpls->mpls_label = label;
417                 key_mpls->mpls_ttl = (entry & MPLS_LS_TTL_MASK)
418                                         >> MPLS_LS_TTL_SHIFT;
419                 key_mpls->mpls_tc = (entry & MPLS_LS_TC_MASK)
420                                         >> MPLS_LS_TC_SHIFT;
421                 key_mpls->mpls_bos = (entry & MPLS_LS_S_MASK)
422                                         >> MPLS_LS_S_SHIFT;
423         }
424 
425         if (label == MPLS_LABEL_ENTROPY) {
426                 key_keyid = skb_flow_dissector_target(flow_dissector,
427                                                       FLOW_DISSECTOR_KEY_MPLS_ENTROPY,
428                                                       target_container);
429                 key_keyid->keyid = hdr[1].entry & htonl(MPLS_LS_LABEL_MASK);
430         }
431         return FLOW_DISSECT_RET_OUT_GOOD;
432 }
433 
434 static enum flow_dissect_ret
435 __skb_flow_dissect_arp(const struct sk_buff *skb,
436                        struct flow_dissector *flow_dissector,
437                        void *target_container, void *data, int nhoff, int hlen)
438 {
439         struct flow_dissector_key_arp *key_arp;
440         struct {
441                 unsigned char ar_sha[ETH_ALEN];
442                 unsigned char ar_sip[4];
443                 unsigned char ar_tha[ETH_ALEN];
444                 unsigned char ar_tip[4];
445         } *arp_eth, _arp_eth;
446         const struct arphdr *arp;
447         struct arphdr _arp;
448 
449         if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ARP))
450                 return FLOW_DISSECT_RET_OUT_GOOD;
451 
452         arp = __skb_header_pointer(skb, nhoff, sizeof(_arp), data,
453                                    hlen, &_arp);
454         if (!arp)
455                 return FLOW_DISSECT_RET_OUT_BAD;
456 
457         if (arp->ar_hrd != htons(ARPHRD_ETHER) ||
458             arp->ar_pro != htons(ETH_P_IP) ||
459             arp->ar_hln != ETH_ALEN ||
460             arp->ar_pln != 4 ||
461             (arp->ar_op != htons(ARPOP_REPLY) &&
462              arp->ar_op != htons(ARPOP_REQUEST)))
463                 return FLOW_DISSECT_RET_OUT_BAD;
464 
465         arp_eth = __skb_header_pointer(skb, nhoff + sizeof(_arp),
466                                        sizeof(_arp_eth), data,
467                                        hlen, &_arp_eth);
468         if (!arp_eth)
469                 return FLOW_DISSECT_RET_OUT_BAD;
470 
471         key_arp = skb_flow_dissector_target(flow_dissector,
472                                             FLOW_DISSECTOR_KEY_ARP,
473                                             target_container);
474 
475         memcpy(&key_arp->sip, arp_eth->ar_sip, sizeof(key_arp->sip));
476         memcpy(&key_arp->tip, arp_eth->ar_tip, sizeof(key_arp->tip));
477 
478         /* Only store the lower byte of the opcode;
479          * this covers ARPOP_REPLY and ARPOP_REQUEST.
480          */
481         key_arp->op = ntohs(arp->ar_op) & 0xff;
482 
483         ether_addr_copy(key_arp->sha, arp_eth->ar_sha);
484         ether_addr_copy(key_arp->tha, arp_eth->ar_tha);
485 
486         return FLOW_DISSECT_RET_OUT_GOOD;
487 }
488 
489 static enum flow_dissect_ret
490 __skb_flow_dissect_gre(const struct sk_buff *skb,
491                        struct flow_dissector_key_control *key_control,
492                        struct flow_dissector *flow_dissector,
493                        void *target_container, void *data,
494                        __be16 *p_proto, int *p_nhoff, int *p_hlen,
495                        unsigned int flags)
496 {
497         struct flow_dissector_key_keyid *key_keyid;
498         struct gre_base_hdr *hdr, _hdr;
499         int offset = 0;
500         u16 gre_ver;
501 
502         hdr = __skb_header_pointer(skb, *p_nhoff, sizeof(_hdr),
503                                    data, *p_hlen, &_hdr);
504         if (!hdr)
505                 return FLOW_DISSECT_RET_OUT_BAD;
506 
507         /* Only look inside GRE without routing */
508         if (hdr->flags & GRE_ROUTING)
509                 return FLOW_DISSECT_RET_OUT_GOOD;
510 
511         /* Only look inside GRE for version 0 and 1 */
512         gre_ver = ntohs(hdr->flags & GRE_VERSION);
513         if (gre_ver > 1)
514                 return FLOW_DISSECT_RET_OUT_GOOD;
515 
516         *p_proto = hdr->protocol;
517         if (gre_ver) {
518                 /* Version1 must be PPTP, and check the flags */
519                 if (!(*p_proto == GRE_PROTO_PPP && (hdr->flags & GRE_KEY)))
520                         return FLOW_DISSECT_RET_OUT_GOOD;
521         }
522 
523         offset += sizeof(struct gre_base_hdr);
524 
525         if (hdr->flags & GRE_CSUM)
526                 offset += FIELD_SIZEOF(struct gre_full_hdr, csum) +
527                           FIELD_SIZEOF(struct gre_full_hdr, reserved1);
528 
529         if (hdr->flags & GRE_KEY) {
530                 const __be32 *keyid;
531                 __be32 _keyid;
532 
533                 keyid = __skb_header_pointer(skb, *p_nhoff + offset,
534                                              sizeof(_keyid),
535                                              data, *p_hlen, &_keyid);
536                 if (!keyid)
537                         return FLOW_DISSECT_RET_OUT_BAD;
538 
539                 if (dissector_uses_key(flow_dissector,
540                                        FLOW_DISSECTOR_KEY_GRE_KEYID)) {
541                         key_keyid = skb_flow_dissector_target(flow_dissector,
542                                                               FLOW_DISSECTOR_KEY_GRE_KEYID,
543                                                               target_container);
544                         if (gre_ver == 0)
545                                 key_keyid->keyid = *keyid;
546                         else
547                                 key_keyid->keyid = *keyid & GRE_PPTP_KEY_MASK;
548                 }
549                 offset += FIELD_SIZEOF(struct gre_full_hdr, key);
550         }
551 
552         if (hdr->flags & GRE_SEQ)
553                 offset += FIELD_SIZEOF(struct pptp_gre_header, seq);
554 
555         if (gre_ver == 0) {
556                 if (*p_proto == htons(ETH_P_TEB)) {
557                         const struct ethhdr *eth;
558                         struct ethhdr _eth;
559 
560                         eth = __skb_header_pointer(skb, *p_nhoff + offset,
561                                                    sizeof(_eth),
562                                                    data, *p_hlen, &_eth);
563                         if (!eth)
564                                 return FLOW_DISSECT_RET_OUT_BAD;
565                         *p_proto = eth->h_proto;
566                         offset += sizeof(*eth);
567 
568                         /* Cap headers that we access via pointers at the
569                          * end of the Ethernet header as our maximum alignment
570                          * at that point is only 2 bytes.
571                          */
572                         if (NET_IP_ALIGN)
573                                 *p_hlen = *p_nhoff + offset;
574                 }
575         } else { /* version 1, must be PPTP */
576                 u8 _ppp_hdr[PPP_HDRLEN];
577                 u8 *ppp_hdr;
578 
579                 if (hdr->flags & GRE_ACK)
580                         offset += FIELD_SIZEOF(struct pptp_gre_header, ack);
581 
582                 ppp_hdr = __skb_header_pointer(skb, *p_nhoff + offset,
583                                                sizeof(_ppp_hdr),
584                                                data, *p_hlen, _ppp_hdr);
585                 if (!ppp_hdr)
586                         return FLOW_DISSECT_RET_OUT_BAD;
587 
588                 switch (PPP_PROTOCOL(ppp_hdr)) {
589                 case PPP_IP:
590                         *p_proto = htons(ETH_P_IP);
591                         break;
592                 case PPP_IPV6:
593                         *p_proto = htons(ETH_P_IPV6);
594                         break;
595                 default:
596                         /* Could probably catch some more like MPLS */
597                         break;
598                 }
599 
600                 offset += PPP_HDRLEN;
601         }
602 
603         *p_nhoff += offset;
604         key_control->flags |= FLOW_DIS_ENCAPSULATION;
605         if (flags & FLOW_DISSECTOR_F_STOP_AT_ENCAP)
606                 return FLOW_DISSECT_RET_OUT_GOOD;
607 
608         return FLOW_DISSECT_RET_PROTO_AGAIN;
609 }
610 
611 /**
612  * __skb_flow_dissect_batadv() - dissect batman-adv header
613  * @skb: sk_buff to with the batman-adv header
614  * @key_control: flow dissectors control key
615  * @data: raw buffer pointer to the packet, if NULL use skb->data
616  * @p_proto: pointer used to update the protocol to process next
617  * @p_nhoff: pointer used to update inner network header offset
618  * @hlen: packet header length
619  * @flags: any combination of FLOW_DISSECTOR_F_*
620  *
621  * ETH_P_BATMAN packets are tried to be dissected. Only
622  * &struct batadv_unicast packets are actually processed because they contain an
623  * inner ethernet header and are usually followed by actual network header. This
624  * allows the flow dissector to continue processing the packet.
625  *
626  * Return: FLOW_DISSECT_RET_PROTO_AGAIN when &struct batadv_unicast was found,
627  *  FLOW_DISSECT_RET_OUT_GOOD when dissector should stop after encapsulation,
628  *  otherwise FLOW_DISSECT_RET_OUT_BAD
629  */
630 static enum flow_dissect_ret
631 __skb_flow_dissect_batadv(const struct sk_buff *skb,
632                           struct flow_dissector_key_control *key_control,
633                           void *data, __be16 *p_proto, int *p_nhoff, int hlen,
634                           unsigned int flags)
635 {
636         struct {
637                 struct batadv_unicast_packet batadv_unicast;
638                 struct ethhdr eth;
639         } *hdr, _hdr;
640 
641         hdr = __skb_header_pointer(skb, *p_nhoff, sizeof(_hdr), data, hlen,
642                                    &_hdr);
643         if (!hdr)
644                 return FLOW_DISSECT_RET_OUT_BAD;
645 
646         if (hdr->batadv_unicast.version != BATADV_COMPAT_VERSION)
647                 return FLOW_DISSECT_RET_OUT_BAD;
648 
649         if (hdr->batadv_unicast.packet_type != BATADV_UNICAST)
650                 return FLOW_DISSECT_RET_OUT_BAD;
651 
652         *p_proto = hdr->eth.h_proto;
653         *p_nhoff += sizeof(*hdr);
654 
655         key_control->flags |= FLOW_DIS_ENCAPSULATION;
656         if (flags & FLOW_DISSECTOR_F_STOP_AT_ENCAP)
657                 return FLOW_DISSECT_RET_OUT_GOOD;
658 
659         return FLOW_DISSECT_RET_PROTO_AGAIN;
660 }
661 
662 static void
663 __skb_flow_dissect_tcp(const struct sk_buff *skb,
664                        struct flow_dissector *flow_dissector,
665                        void *target_container, void *data, int thoff, int hlen)
666 {
667         struct flow_dissector_key_tcp *key_tcp;
668         struct tcphdr *th, _th;
669 
670         if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_TCP))
671                 return;
672 
673         th = __skb_header_pointer(skb, thoff, sizeof(_th), data, hlen, &_th);
674         if (!th)
675                 return;
676 
677         if (unlikely(__tcp_hdrlen(th) < sizeof(_th)))
678                 return;
679 
680         key_tcp = skb_flow_dissector_target(flow_dissector,
681                                             FLOW_DISSECTOR_KEY_TCP,
682                                             target_container);
683         key_tcp->flags = (*(__be16 *) &tcp_flag_word(th) & htons(0x0FFF));
684 }
685 
686 static void
687 __skb_flow_dissect_ipv4(const struct sk_buff *skb,
688                         struct flow_dissector *flow_dissector,
689                         void *target_container, void *data, const struct iphdr *iph)
690 {
691         struct flow_dissector_key_ip *key_ip;
692 
693         if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_IP))
694                 return;
695 
696         key_ip = skb_flow_dissector_target(flow_dissector,
697                                            FLOW_DISSECTOR_KEY_IP,
698                                            target_container);
699         key_ip->tos = iph->tos;
700         key_ip->ttl = iph->ttl;
701 }
702 
703 static void
704 __skb_flow_dissect_ipv6(const struct sk_buff *skb,
705                         struct flow_dissector *flow_dissector,
706                         void *target_container, void *data, const struct ipv6hdr *iph)
707 {
708         struct flow_dissector_key_ip *key_ip;
709 
710         if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_IP))
711                 return;
712 
713         key_ip = skb_flow_dissector_target(flow_dissector,
714                                            FLOW_DISSECTOR_KEY_IP,
715                                            target_container);
716         key_ip->tos = ipv6_get_dsfield(iph);
717         key_ip->ttl = iph->hop_limit;
718 }
719 
720 /* Maximum number of protocol headers that can be parsed in
721  * __skb_flow_dissect
722  */
723 #define MAX_FLOW_DISSECT_HDRS   15
724 
725 static bool skb_flow_dissect_allowed(int *num_hdrs)
726 {
727         ++*num_hdrs;
728 
729         return (*num_hdrs <= MAX_FLOW_DISSECT_HDRS);
730 }
731 
732 static void __skb_flow_bpf_to_target(const struct bpf_flow_keys *flow_keys,
733                                      struct flow_dissector *flow_dissector,
734                                      void *target_container)
735 {
736         struct flow_dissector_key_control *key_control;
737         struct flow_dissector_key_basic *key_basic;
738         struct flow_dissector_key_addrs *key_addrs;
739         struct flow_dissector_key_ports *key_ports;
740 
741         key_control = skb_flow_dissector_target(flow_dissector,
742                                                 FLOW_DISSECTOR_KEY_CONTROL,
743                                                 target_container);
744         key_control->thoff = flow_keys->thoff;
745         if (flow_keys->is_frag)
746                 key_control->flags |= FLOW_DIS_IS_FRAGMENT;
747         if (flow_keys->is_first_frag)
748                 key_control->flags |= FLOW_DIS_FIRST_FRAG;
749         if (flow_keys->is_encap)
750                 key_control->flags |= FLOW_DIS_ENCAPSULATION;
751 
752         key_basic = skb_flow_dissector_target(flow_dissector,
753                                               FLOW_DISSECTOR_KEY_BASIC,
754                                               target_container);
755         key_basic->n_proto = flow_keys->n_proto;
756         key_basic->ip_proto = flow_keys->ip_proto;
757 
758         if (flow_keys->addr_proto == ETH_P_IP &&
759             dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_IPV4_ADDRS)) {
760                 key_addrs = skb_flow_dissector_target(flow_dissector,
761                                                       FLOW_DISSECTOR_KEY_IPV4_ADDRS,
762                                                       target_container);
763                 key_addrs->v4addrs.src = flow_keys->ipv4_src;
764                 key_addrs->v4addrs.dst = flow_keys->ipv4_dst;
765                 key_control->addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
766         } else if (flow_keys->addr_proto == ETH_P_IPV6 &&
767                    dissector_uses_key(flow_dissector,
768                                       FLOW_DISSECTOR_KEY_IPV6_ADDRS)) {
769                 key_addrs = skb_flow_dissector_target(flow_dissector,
770                                                       FLOW_DISSECTOR_KEY_IPV6_ADDRS,
771                                                       target_container);
772                 memcpy(&key_addrs->v6addrs, &flow_keys->ipv6_src,
773                        sizeof(key_addrs->v6addrs));
774                 key_control->addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
775         }
776 
777         if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_PORTS)) {
778                 key_ports = skb_flow_dissector_target(flow_dissector,
779                                                       FLOW_DISSECTOR_KEY_PORTS,
780                                                       target_container);
781                 key_ports->src = flow_keys->sport;
782                 key_ports->dst = flow_keys->dport;
783         }
784 }
785 
786 bool bpf_flow_dissect(struct bpf_prog *prog, struct bpf_flow_dissector *ctx,
787                       __be16 proto, int nhoff, int hlen)
788 {
789         struct bpf_flow_keys *flow_keys = ctx->flow_keys;
790         u32 result;
791 
792         /* Pass parameters to the BPF program */
793         memset(flow_keys, 0, sizeof(*flow_keys));
794         flow_keys->n_proto = proto;
795         flow_keys->nhoff = nhoff;
796         flow_keys->thoff = flow_keys->nhoff;
797 
798         preempt_disable();
799         result = BPF_PROG_RUN(prog, ctx);
800         preempt_enable();
801 
802         flow_keys->nhoff = clamp_t(u16, flow_keys->nhoff, nhoff, hlen);
803         flow_keys->thoff = clamp_t(u16, flow_keys->thoff,
804                                    flow_keys->nhoff, hlen);
805 
806         return result == BPF_OK;
807 }
808 
809 /**
810  * __skb_flow_dissect - extract the flow_keys struct and return it
811  * @net: associated network namespace, derived from @skb if NULL
812  * @skb: sk_buff to extract the flow from, can be NULL if the rest are specified
813  * @flow_dissector: list of keys to dissect
814  * @target_container: target structure to put dissected values into
815  * @data: raw buffer pointer to the packet, if NULL use skb->data
816  * @proto: protocol for which to get the flow, if @data is NULL use skb->protocol
817  * @nhoff: network header offset, if @data is NULL use skb_network_offset(skb)
818  * @hlen: packet header length, if @data is NULL use skb_headlen(skb)
819  * @flags: flags that control the dissection process, e.g.
820  *         FLOW_DISSECTOR_F_STOP_AT_ENCAP.
821  *
822  * The function will try to retrieve individual keys into target specified
823  * by flow_dissector from either the skbuff or a raw buffer specified by the
824  * rest parameters.
825  *
826  * Caller must take care of zeroing target container memory.
827  */
828 bool __skb_flow_dissect(const struct net *net,
829                         const struct sk_buff *skb,
830                         struct flow_dissector *flow_dissector,
831                         void *target_container,
832                         void *data, __be16 proto, int nhoff, int hlen,
833                         unsigned int flags)
834 {
835         struct flow_dissector_key_control *key_control;
836         struct flow_dissector_key_basic *key_basic;
837         struct flow_dissector_key_addrs *key_addrs;
838         struct flow_dissector_key_ports *key_ports;
839         struct flow_dissector_key_icmp *key_icmp;
840         struct flow_dissector_key_tags *key_tags;
841         struct flow_dissector_key_vlan *key_vlan;
842         struct bpf_prog *attached = NULL;
843         enum flow_dissect_ret fdret;
844         enum flow_dissector_key_id dissector_vlan = FLOW_DISSECTOR_KEY_MAX;
845         int num_hdrs = 0;
846         u8 ip_proto = 0;
847         bool ret;
848 
849         if (!data) {
850                 data = skb->data;
851                 proto = skb_vlan_tag_present(skb) ?
852                          skb->vlan_proto : skb->protocol;
853                 nhoff = skb_network_offset(skb);
854                 hlen = skb_headlen(skb);
855 #if IS_ENABLED(CONFIG_NET_DSA)
856                 if (unlikely(skb->dev && netdev_uses_dsa(skb->dev) &&
857                              proto == htons(ETH_P_XDSA))) {
858                         const struct dsa_device_ops *ops;
859                         int offset = 0;
860 
861                         ops = skb->dev->dsa_ptr->tag_ops;
862                         if (ops->flow_dissect &&
863                             !ops->flow_dissect(skb, &proto, &offset)) {
864                                 hlen -= offset;
865                                 nhoff += offset;
866                         }
867                 }
868 #endif
869         }
870 
871         /* It is ensured by skb_flow_dissector_init() that control key will
872          * be always present.
873          */
874         key_control = skb_flow_dissector_target(flow_dissector,
875                                                 FLOW_DISSECTOR_KEY_CONTROL,
876                                                 target_container);
877 
878         /* It is ensured by skb_flow_dissector_init() that basic key will
879          * be always present.
880          */
881         key_basic = skb_flow_dissector_target(flow_dissector,
882                                               FLOW_DISSECTOR_KEY_BASIC,
883                                               target_container);
884 
885         if (skb) {
886                 if (!net) {
887                         if (skb->dev)
888                                 net = dev_net(skb->dev);
889                         else if (skb->sk)
890                                 net = sock_net(skb->sk);
891                 }
892         }
893 
894         WARN_ON_ONCE(!net);
895         if (net) {
896                 rcu_read_lock();
897                 attached = rcu_dereference(net->flow_dissector_prog);
898 
899                 if (attached) {
900                         struct bpf_flow_keys flow_keys;
901                         struct bpf_flow_dissector ctx = {
902                                 .flow_keys = &flow_keys,
903                                 .data = data,
904                                 .data_end = data + hlen,
905                         };
906                         __be16 n_proto = proto;
907 
908                         if (skb) {
909                                 ctx.skb = skb;
910                                 /* we can't use 'proto' in the skb case
911                                  * because it might be set to skb->vlan_proto
912                                  * which has been pulled from the data
913                                  */
914                                 n_proto = skb->protocol;
915                         }
916 
917                         ret = bpf_flow_dissect(attached, &ctx, n_proto, nhoff,
918                                                hlen);
919                         __skb_flow_bpf_to_target(&flow_keys, flow_dissector,
920                                                  target_container);
921                         rcu_read_unlock();
922                         return ret;
923                 }
924                 rcu_read_unlock();
925         }
926 
927         if (dissector_uses_key(flow_dissector,
928                                FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
929                 struct ethhdr *eth = eth_hdr(skb);
930                 struct flow_dissector_key_eth_addrs *key_eth_addrs;
931 
932                 key_eth_addrs = skb_flow_dissector_target(flow_dissector,
933                                                           FLOW_DISSECTOR_KEY_ETH_ADDRS,
934                                                           target_container);
935                 memcpy(key_eth_addrs, &eth->h_dest, sizeof(*key_eth_addrs));
936         }
937 
938 proto_again:
939         fdret = FLOW_DISSECT_RET_CONTINUE;
940 
941         switch (proto) {
942         case htons(ETH_P_IP): {
943                 const struct iphdr *iph;
944                 struct iphdr _iph;
945 
946                 iph = __skb_header_pointer(skb, nhoff, sizeof(_iph), data, hlen, &_iph);
947                 if (!iph || iph->ihl < 5) {
948                         fdret = FLOW_DISSECT_RET_OUT_BAD;
949                         break;
950                 }
951 
952                 nhoff += iph->ihl * 4;
953 
954                 ip_proto = iph->protocol;
955 
956                 if (dissector_uses_key(flow_dissector,
957                                        FLOW_DISSECTOR_KEY_IPV4_ADDRS)) {
958                         key_addrs = skb_flow_dissector_target(flow_dissector,
959                                                               FLOW_DISSECTOR_KEY_IPV4_ADDRS,
960                                                               target_container);
961 
962                         memcpy(&key_addrs->v4addrs, &iph->saddr,
963                                sizeof(key_addrs->v4addrs));
964                         key_control->addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
965                 }
966 
967                 if (ip_is_fragment(iph)) {
968                         key_control->flags |= FLOW_DIS_IS_FRAGMENT;
969 
970                         if (iph->frag_off & htons(IP_OFFSET)) {
971                                 fdret = FLOW_DISSECT_RET_OUT_GOOD;
972                                 break;
973                         } else {
974                                 key_control->flags |= FLOW_DIS_FIRST_FRAG;
975                                 if (!(flags &
976                                       FLOW_DISSECTOR_F_PARSE_1ST_FRAG)) {
977                                         fdret = FLOW_DISSECT_RET_OUT_GOOD;
978                                         break;
979                                 }
980                         }
981                 }
982 
983                 __skb_flow_dissect_ipv4(skb, flow_dissector,
984                                         target_container, data, iph);
985 
986                 break;
987         }
988         case htons(ETH_P_IPV6): {
989                 const struct ipv6hdr *iph;
990                 struct ipv6hdr _iph;
991 
992                 iph = __skb_header_pointer(skb, nhoff, sizeof(_iph), data, hlen, &_iph);
993                 if (!iph) {
994                         fdret = FLOW_DISSECT_RET_OUT_BAD;
995                         break;
996                 }
997 
998                 ip_proto = iph->nexthdr;
999                 nhoff += sizeof(struct ipv6hdr);
1000 
1001                 if (dissector_uses_key(flow_dissector,
1002                                        FLOW_DISSECTOR_KEY_IPV6_ADDRS)) {
1003                         key_addrs = skb_flow_dissector_target(flow_dissector,
1004                                                               FLOW_DISSECTOR_KEY_IPV6_ADDRS,
1005                                                               target_container);
1006 
1007                         memcpy(&key_addrs->v6addrs, &iph->saddr,
1008                                sizeof(key_addrs->v6addrs));
1009                         key_control->addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
1010                 }
1011 
1012                 if ((dissector_uses_key(flow_dissector,
1013                                         FLOW_DISSECTOR_KEY_FLOW_LABEL) ||
1014                      (flags & FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL)) &&
1015                     ip6_flowlabel(iph)) {
1016                         __be32 flow_label = ip6_flowlabel(iph);
1017 
1018                         if (dissector_uses_key(flow_dissector,
1019                                                FLOW_DISSECTOR_KEY_FLOW_LABEL)) {
1020                                 key_tags = skb_flow_dissector_target(flow_dissector,
1021                                                                      FLOW_DISSECTOR_KEY_FLOW_LABEL,
1022                                                                      target_container);
1023                                 key_tags->flow_label = ntohl(flow_label);
1024                         }
1025                         if (flags & FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL) {
1026                                 fdret = FLOW_DISSECT_RET_OUT_GOOD;
1027                                 break;
1028                         }
1029                 }
1030 
1031                 __skb_flow_dissect_ipv6(skb, flow_dissector,
1032                                         target_container, data, iph);
1033 
1034                 break;
1035         }
1036         case htons(ETH_P_8021AD):
1037         case htons(ETH_P_8021Q): {
1038                 const struct vlan_hdr *vlan = NULL;
1039                 struct vlan_hdr _vlan;
1040                 __be16 saved_vlan_tpid = proto;
1041 
1042                 if (dissector_vlan == FLOW_DISSECTOR_KEY_MAX &&
1043                     skb && skb_vlan_tag_present(skb)) {
1044                         proto = skb->protocol;
1045                 } else {
1046                         vlan = __skb_header_pointer(skb, nhoff, sizeof(_vlan),
1047                                                     data, hlen, &_vlan);
1048                         if (!vlan) {
1049                                 fdret = FLOW_DISSECT_RET_OUT_BAD;
1050                                 break;
1051                         }
1052 
1053                         proto = vlan->h_vlan_encapsulated_proto;
1054                         nhoff += sizeof(*vlan);
1055                 }
1056 
1057                 if (dissector_vlan == FLOW_DISSECTOR_KEY_MAX) {
1058                         dissector_vlan = FLOW_DISSECTOR_KEY_VLAN;
1059                 } else if (dissector_vlan == FLOW_DISSECTOR_KEY_VLAN) {
1060                         dissector_vlan = FLOW_DISSECTOR_KEY_CVLAN;
1061                 } else {
1062                         fdret = FLOW_DISSECT_RET_PROTO_AGAIN;
1063                         break;
1064                 }
1065 
1066                 if (dissector_uses_key(flow_dissector, dissector_vlan)) {
1067                         key_vlan = skb_flow_dissector_target(flow_dissector,
1068                                                              dissector_vlan,
1069                                                              target_container);
1070 
1071                         if (!vlan) {
1072                                 key_vlan->vlan_id = skb_vlan_tag_get_id(skb);
1073                                 key_vlan->vlan_priority = skb_vlan_tag_get_prio(skb);
1074                         } else {
1075                                 key_vlan->vlan_id = ntohs(vlan->h_vlan_TCI) &
1076                                         VLAN_VID_MASK;
1077                                 key_vlan->vlan_priority =
1078                                         (ntohs(vlan->h_vlan_TCI) &
1079                                          VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
1080                         }
1081                         key_vlan->vlan_tpid = saved_vlan_tpid;
1082                 }
1083 
1084                 fdret = FLOW_DISSECT_RET_PROTO_AGAIN;
1085                 break;
1086         }
1087         case htons(ETH_P_PPP_SES): {
1088                 struct {
1089                         struct pppoe_hdr hdr;
1090                         __be16 proto;
1091                 } *hdr, _hdr;
1092                 hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data, hlen, &_hdr);
1093                 if (!hdr) {
1094                         fdret = FLOW_DISSECT_RET_OUT_BAD;
1095                         break;
1096                 }
1097 
1098                 proto = hdr->proto;
1099                 nhoff += PPPOE_SES_HLEN;
1100                 switch (proto) {
1101                 case htons(PPP_IP):
1102                         proto = htons(ETH_P_IP);
1103                         fdret = FLOW_DISSECT_RET_PROTO_AGAIN;
1104                         break;
1105                 case htons(PPP_IPV6):
1106                         proto = htons(ETH_P_IPV6);
1107                         fdret = FLOW_DISSECT_RET_PROTO_AGAIN;
1108                         break;
1109                 default:
1110                         fdret = FLOW_DISSECT_RET_OUT_BAD;
1111                         break;
1112                 }
1113                 break;
1114         }
1115         case htons(ETH_P_TIPC): {
1116                 struct tipc_basic_hdr *hdr, _hdr;
1117 
1118                 hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr),
1119                                            data, hlen, &_hdr);
1120                 if (!hdr) {
1121                         fdret = FLOW_DISSECT_RET_OUT_BAD;
1122                         break;
1123                 }
1124 
1125                 if (dissector_uses_key(flow_dissector,
1126                                        FLOW_DISSECTOR_KEY_TIPC)) {
1127                         key_addrs = skb_flow_dissector_target(flow_dissector,
1128                                                               FLOW_DISSECTOR_KEY_TIPC,
1129                                                               target_container);
1130                         key_addrs->tipckey.key = tipc_hdr_rps_key(hdr);
1131                         key_control->addr_type = FLOW_DISSECTOR_KEY_TIPC;
1132                 }
1133                 fdret = FLOW_DISSECT_RET_OUT_GOOD;
1134                 break;
1135         }
1136 
1137         case htons(ETH_P_MPLS_UC):
1138         case htons(ETH_P_MPLS_MC):
1139                 fdret = __skb_flow_dissect_mpls(skb, flow_dissector,
1140                                                 target_container, data,
1141                                                 nhoff, hlen);
1142                 break;
1143         case htons(ETH_P_FCOE):
1144                 if ((hlen - nhoff) < FCOE_HEADER_LEN) {
1145                         fdret = FLOW_DISSECT_RET_OUT_BAD;
1146                         break;
1147                 }
1148 
1149                 nhoff += FCOE_HEADER_LEN;
1150                 fdret = FLOW_DISSECT_RET_OUT_GOOD;
1151                 break;
1152 
1153         case htons(ETH_P_ARP):
1154         case htons(ETH_P_RARP):
1155                 fdret = __skb_flow_dissect_arp(skb, flow_dissector,
1156                                                target_container, data,
1157                                                nhoff, hlen);
1158                 break;
1159 
1160         case htons(ETH_P_BATMAN):
1161                 fdret = __skb_flow_dissect_batadv(skb, key_control, data,
1162                                                   &proto, &nhoff, hlen, flags);
1163                 break;
1164 
1165         default:
1166                 fdret = FLOW_DISSECT_RET_OUT_BAD;
1167                 break;
1168         }
1169 
1170         /* Process result of proto processing */
1171         switch (fdret) {
1172         case FLOW_DISSECT_RET_OUT_GOOD:
1173                 goto out_good;
1174         case FLOW_DISSECT_RET_PROTO_AGAIN:
1175                 if (skb_flow_dissect_allowed(&num_hdrs))
1176                         goto proto_again;
1177                 goto out_good;
1178         case FLOW_DISSECT_RET_CONTINUE:
1179         case FLOW_DISSECT_RET_IPPROTO_AGAIN:
1180                 break;
1181         case FLOW_DISSECT_RET_OUT_BAD:
1182         default:
1183                 goto out_bad;
1184         }
1185 
1186 ip_proto_again:
1187         fdret = FLOW_DISSECT_RET_CONTINUE;
1188 
1189         switch (ip_proto) {
1190         case IPPROTO_GRE:
1191                 fdret = __skb_flow_dissect_gre(skb, key_control, flow_dissector,
1192                                                target_container, data,
1193                                                &proto, &nhoff, &hlen, flags);
1194                 break;
1195 
1196         case NEXTHDR_HOP:
1197         case NEXTHDR_ROUTING:
1198         case NEXTHDR_DEST: {
1199                 u8 _opthdr[2], *opthdr;
1200 
1201                 if (proto != htons(ETH_P_IPV6))
1202                         break;
1203 
1204                 opthdr = __skb_header_pointer(skb, nhoff, sizeof(_opthdr),
1205                                               data, hlen, &_opthdr);
1206                 if (!opthdr) {
1207                         fdret = FLOW_DISSECT_RET_OUT_BAD;
1208                         break;
1209                 }
1210 
1211                 ip_proto = opthdr[0];
1212                 nhoff += (opthdr[1] + 1) << 3;
1213 
1214                 fdret = FLOW_DISSECT_RET_IPPROTO_AGAIN;
1215                 break;
1216         }
1217         case NEXTHDR_FRAGMENT: {
1218                 struct frag_hdr _fh, *fh;
1219 
1220                 if (proto != htons(ETH_P_IPV6))
1221                         break;
1222 
1223                 fh = __skb_header_pointer(skb, nhoff, sizeof(_fh),
1224                                           data, hlen, &_fh);
1225 
1226                 if (!fh) {
1227                         fdret = FLOW_DISSECT_RET_OUT_BAD;
1228                         break;
1229                 }
1230 
1231                 key_control->flags |= FLOW_DIS_IS_FRAGMENT;
1232 
1233                 nhoff += sizeof(_fh);
1234                 ip_proto = fh->nexthdr;
1235 
1236                 if (!(fh->frag_off & htons(IP6_OFFSET))) {
1237                         key_control->flags |= FLOW_DIS_FIRST_FRAG;
1238                         if (flags & FLOW_DISSECTOR_F_PARSE_1ST_FRAG) {
1239                                 fdret = FLOW_DISSECT_RET_IPPROTO_AGAIN;
1240                                 break;
1241                         }
1242                 }
1243 
1244                 fdret = FLOW_DISSECT_RET_OUT_GOOD;
1245                 break;
1246         }
1247         case IPPROTO_IPIP:
1248                 proto = htons(ETH_P_IP);
1249 
1250                 key_control->flags |= FLOW_DIS_ENCAPSULATION;
1251                 if (flags & FLOW_DISSECTOR_F_STOP_AT_ENCAP) {
1252                         fdret = FLOW_DISSECT_RET_OUT_GOOD;
1253                         break;
1254                 }
1255 
1256                 fdret = FLOW_DISSECT_RET_PROTO_AGAIN;
1257                 break;
1258 
1259         case IPPROTO_IPV6:
1260                 proto = htons(ETH_P_IPV6);
1261 
1262                 key_control->flags |= FLOW_DIS_ENCAPSULATION;
1263                 if (flags & FLOW_DISSECTOR_F_STOP_AT_ENCAP) {
1264                         fdret = FLOW_DISSECT_RET_OUT_GOOD;
1265                         break;
1266                 }
1267 
1268                 fdret = FLOW_DISSECT_RET_PROTO_AGAIN;
1269                 break;
1270 
1271 
1272         case IPPROTO_MPLS:
1273                 proto = htons(ETH_P_MPLS_UC);
1274                 fdret = FLOW_DISSECT_RET_PROTO_AGAIN;
1275                 break;
1276 
1277         case IPPROTO_TCP:
1278                 __skb_flow_dissect_tcp(skb, flow_dissector, target_container,
1279                                        data, nhoff, hlen);
1280                 break;
1281 
1282         default:
1283                 break;
1284         }
1285 
1286         if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_PORTS) &&
1287             !(key_control->flags & FLOW_DIS_IS_FRAGMENT)) {
1288                 key_ports = skb_flow_dissector_target(flow_dissector,
1289                                                       FLOW_DISSECTOR_KEY_PORTS,
1290                                                       target_container);
1291                 key_ports->ports = __skb_flow_get_ports(skb, nhoff, ip_proto,
1292                                                         data, hlen);
1293         }
1294 
1295         if (dissector_uses_key(flow_dissector,
1296                                FLOW_DISSECTOR_KEY_ICMP)) {
1297                 key_icmp = skb_flow_dissector_target(flow_dissector,
1298                                                      FLOW_DISSECTOR_KEY_ICMP,
1299                                                      target_container);
1300                 key_icmp->icmp = skb_flow_get_be16(skb, nhoff, data, hlen);
1301         }
1302 
1303         /* Process result of IP proto processing */
1304         switch (fdret) {
1305         case FLOW_DISSECT_RET_PROTO_AGAIN:
1306                 if (skb_flow_dissect_allowed(&num_hdrs))
1307                         goto proto_again;
1308                 break;
1309         case FLOW_DISSECT_RET_IPPROTO_AGAIN:
1310                 if (skb_flow_dissect_allowed(&num_hdrs))
1311                         goto ip_proto_again;
1312                 break;
1313         case FLOW_DISSECT_RET_OUT_GOOD:
1314         case FLOW_DISSECT_RET_CONTINUE:
1315                 break;
1316         case FLOW_DISSECT_RET_OUT_BAD:
1317         default:
1318                 goto out_bad;
1319         }
1320 
1321 out_good:
1322         ret = true;
1323 
1324 out:
1325         key_control->thoff = min_t(u16, nhoff, skb ? skb->len : hlen);
1326         key_basic->n_proto = proto;
1327         key_basic->ip_proto = ip_proto;
1328 
1329         return ret;
1330 
1331 out_bad:
1332         ret = false;
1333         goto out;
1334 }
1335 EXPORT_SYMBOL(__skb_flow_dissect);
1336 
1337 static siphash_key_t hashrnd __read_mostly;
1338 static __always_inline void __flow_hash_secret_init(void)
1339 {
1340         net_get_random_once(&hashrnd, sizeof(hashrnd));
1341 }
1342 
1343 static const void *flow_keys_hash_start(const struct flow_keys *flow)
1344 {
1345         BUILD_BUG_ON(FLOW_KEYS_HASH_OFFSET % SIPHASH_ALIGNMENT);
1346         return &flow->FLOW_KEYS_HASH_START_FIELD;
1347 }
1348 
1349 static inline size_t flow_keys_hash_length(const struct flow_keys *flow)
1350 {
1351         size_t diff = FLOW_KEYS_HASH_OFFSET + sizeof(flow->addrs);
1352         BUILD_BUG_ON(offsetof(typeof(*flow), addrs) !=
1353                      sizeof(*flow) - sizeof(flow->addrs));
1354 
1355         switch (flow->control.addr_type) {
1356         case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
1357                 diff -= sizeof(flow->addrs.v4addrs);
1358                 break;
1359         case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
1360                 diff -= sizeof(flow->addrs.v6addrs);
1361                 break;
1362         case FLOW_DISSECTOR_KEY_TIPC:
1363                 diff -= sizeof(flow->addrs.tipckey);
1364                 break;
1365         }
1366         return sizeof(*flow) - diff;
1367 }
1368 
1369 __be32 flow_get_u32_src(const struct flow_keys *flow)
1370 {
1371         switch (flow->control.addr_type) {
1372         case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
1373                 return flow->addrs.v4addrs.src;
1374         case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
1375                 return (__force __be32)ipv6_addr_hash(
1376                         &flow->addrs.v6addrs.src);
1377         case FLOW_DISSECTOR_KEY_TIPC:
1378                 return flow->addrs.tipckey.key;
1379         default:
1380                 return 0;
1381         }
1382 }
1383 EXPORT_SYMBOL(flow_get_u32_src);
1384 
1385 __be32 flow_get_u32_dst(const struct flow_keys *flow)
1386 {
1387         switch (flow->control.addr_type) {
1388         case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
1389                 return flow->addrs.v4addrs.dst;
1390         case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
1391                 return (__force __be32)ipv6_addr_hash(
1392                         &flow->addrs.v6addrs.dst);
1393         default:
1394                 return 0;
1395         }
1396 }
1397 EXPORT_SYMBOL(flow_get_u32_dst);
1398 
1399 static inline void __flow_hash_consistentify(struct flow_keys *keys)
1400 {
1401         int addr_diff, i;
1402 
1403         switch (keys->control.addr_type) {
1404         case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
1405                 addr_diff = (__force u32)keys->addrs.v4addrs.dst -
1406                             (__force u32)keys->addrs.v4addrs.src;
1407                 if ((addr_diff < 0) ||
1408                     (addr_diff == 0 &&
1409                      ((__force u16)keys->ports.dst <
1410                       (__force u16)keys->ports.src))) {
1411                         swap(keys->addrs.v4addrs.src, keys->addrs.v4addrs.dst);
1412                         swap(keys->ports.src, keys->ports.dst);
1413                 }
1414                 break;
1415         case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
1416                 addr_diff = memcmp(&keys->addrs.v6addrs.dst,
1417                                    &keys->addrs.v6addrs.src,
1418                                    sizeof(keys->addrs.v6addrs.dst));
1419                 if ((addr_diff < 0) ||
1420                     (addr_diff == 0 &&
1421                      ((__force u16)keys->ports.dst <
1422                       (__force u16)keys->ports.src))) {
1423                         for (i = 0; i < 4; i++)
1424                                 swap(keys->addrs.v6addrs.src.s6_addr32[i],
1425                                      keys->addrs.v6addrs.dst.s6_addr32[i]);
1426                         swap(keys->ports.src, keys->ports.dst);
1427                 }
1428                 break;
1429         }
1430 }
1431 
1432 static inline u32 __flow_hash_from_keys(struct flow_keys *keys,
1433                                         const siphash_key_t *keyval)
1434 {
1435         u32 hash;
1436 
1437         __flow_hash_consistentify(keys);
1438 
1439         hash = siphash(flow_keys_hash_start(keys),
1440                        flow_keys_hash_length(keys), keyval);
1441         if (!hash)
1442                 hash = 1;
1443 
1444         return hash;
1445 }
1446 
1447 u32 flow_hash_from_keys(struct flow_keys *keys)
1448 {
1449         __flow_hash_secret_init();
1450         return __flow_hash_from_keys(keys, &hashrnd);
1451 }
1452 EXPORT_SYMBOL(flow_hash_from_keys);
1453 
1454 static inline u32 ___skb_get_hash(const struct sk_buff *skb,
1455                                   struct flow_keys *keys,
1456                                   const siphash_key_t *keyval)
1457 {
1458         skb_flow_dissect_flow_keys(skb, keys,
1459                                    FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL);
1460 
1461         return __flow_hash_from_keys(keys, keyval);
1462 }
1463 
1464 struct _flow_keys_digest_data {
1465         __be16  n_proto;
1466         u8      ip_proto;
1467         u8      padding;
1468         __be32  ports;
1469         __be32  src;
1470         __be32  dst;
1471 };
1472 
1473 void make_flow_keys_digest(struct flow_keys_digest *digest,
1474                            const struct flow_keys *flow)
1475 {
1476         struct _flow_keys_digest_data *data =
1477             (struct _flow_keys_digest_data *)digest;
1478 
1479         BUILD_BUG_ON(sizeof(*data) > sizeof(*digest));
1480 
1481         memset(digest, 0, sizeof(*digest));
1482 
1483         data->n_proto = flow->basic.n_proto;
1484         data->ip_proto = flow->basic.ip_proto;
1485         data->ports = flow->ports.ports;
1486         data->src = flow->addrs.v4addrs.src;
1487         data->dst = flow->addrs.v4addrs.dst;
1488 }
1489 EXPORT_SYMBOL(make_flow_keys_digest);
1490 
1491 static struct flow_dissector flow_keys_dissector_symmetric __read_mostly;
1492 
1493 u32 __skb_get_hash_symmetric(const struct sk_buff *skb)
1494 {
1495         struct flow_keys keys;
1496 
1497         __flow_hash_secret_init();
1498 
1499         memset(&keys, 0, sizeof(keys));
1500         __skb_flow_dissect(NULL, skb, &flow_keys_dissector_symmetric,
1501                            &keys, NULL, 0, 0, 0,
1502                            FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL);
1503 
1504         return __flow_hash_from_keys(&keys, &hashrnd);
1505 }
1506 EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric);
1507 
1508 /**
1509  * __skb_get_hash: calculate a flow hash
1510  * @skb: sk_buff to calculate flow hash from
1511  *
1512  * This function calculates a flow hash based on src/dst addresses
1513  * and src/dst port numbers.  Sets hash in skb to non-zero hash value
1514  * on success, zero indicates no valid hash.  Also, sets l4_hash in skb
1515  * if hash is a canonical 4-tuple hash over transport ports.
1516  */
1517 void __skb_get_hash(struct sk_buff *skb)
1518 {
1519         struct flow_keys keys;
1520         u32 hash;
1521 
1522         __flow_hash_secret_init();
1523 
1524         hash = ___skb_get_hash(skb, &keys, &hashrnd);
1525 
1526         __skb_set_sw_hash(skb, hash, flow_keys_have_l4(&keys));
1527 }
1528 EXPORT_SYMBOL(__skb_get_hash);
1529 
1530 __u32 skb_get_hash_perturb(const struct sk_buff *skb,
1531                            const siphash_key_t *perturb)
1532 {
1533         struct flow_keys keys;
1534 
1535         return ___skb_get_hash(skb, &keys, perturb);
1536 }
1537 EXPORT_SYMBOL(skb_get_hash_perturb);
1538 
1539 u32 __skb_get_poff(const struct sk_buff *skb, void *data,
1540                    const struct flow_keys_basic *keys, int hlen)
1541 {
1542         u32 poff = keys->control.thoff;
1543 
1544         /* skip L4 headers for fragments after the first */
1545         if ((keys->control.flags & FLOW_DIS_IS_FRAGMENT) &&
1546             !(keys->control.flags & FLOW_DIS_FIRST_FRAG))
1547                 return poff;
1548 
1549         switch (keys->basic.ip_proto) {
1550         case IPPROTO_TCP: {
1551                 /* access doff as u8 to avoid unaligned access */
1552                 const u8 *doff;
1553                 u8 _doff;
1554 
1555                 doff = __skb_header_pointer(skb, poff + 12, sizeof(_doff),
1556                                             data, hlen, &_doff);
1557                 if (!doff)
1558                         return poff;
1559 
1560                 poff += max_t(u32, sizeof(struct tcphdr), (*doff & 0xF0) >> 2);
1561                 break;
1562         }
1563         case IPPROTO_UDP:
1564         case IPPROTO_UDPLITE:
1565                 poff += sizeof(struct udphdr);
1566                 break;
1567         /* For the rest, we do not really care about header
1568          * extensions at this point for now.
1569          */
1570         case IPPROTO_ICMP:
1571                 poff += sizeof(struct icmphdr);
1572                 break;
1573         case IPPROTO_ICMPV6:
1574                 poff += sizeof(struct icmp6hdr);
1575                 break;
1576         case IPPROTO_IGMP:
1577                 poff += sizeof(struct igmphdr);
1578                 break;
1579         case IPPROTO_DCCP:
1580                 poff += sizeof(struct dccp_hdr);
1581                 break;
1582         case IPPROTO_SCTP:
1583                 poff += sizeof(struct sctphdr);
1584                 break;
1585         }
1586 
1587         return poff;
1588 }
1589 
1590 /**
1591  * skb_get_poff - get the offset to the payload
1592  * @skb: sk_buff to get the payload offset from
1593  *
1594  * The function will get the offset to the payload as far as it could
1595  * be dissected.  The main user is currently BPF, so that we can dynamically
1596  * truncate packets without needing to push actual payload to the user
1597  * space and can analyze headers only, instead.
1598  */
1599 u32 skb_get_poff(const struct sk_buff *skb)
1600 {
1601         struct flow_keys_basic keys;
1602 
1603         if (!skb_flow_dissect_flow_keys_basic(NULL, skb, &keys,
1604                                               NULL, 0, 0, 0, 0))
1605                 return 0;
1606 
1607         return __skb_get_poff(skb, skb->data, &keys, skb_headlen(skb));
1608 }
1609 
1610 __u32 __get_hash_from_flowi6(const struct flowi6 *fl6, struct flow_keys *keys)
1611 {
1612         memset(keys, 0, sizeof(*keys));
1613 
1614         memcpy(&keys->addrs.v6addrs.src, &fl6->saddr,
1615             sizeof(keys->addrs.v6addrs.src));
1616         memcpy(&keys->addrs.v6addrs.dst, &fl6->daddr,
1617             sizeof(keys->addrs.v6addrs.dst));
1618         keys->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
1619         keys->ports.src = fl6->fl6_sport;
1620         keys->ports.dst = fl6->fl6_dport;
1621         keys->keyid.keyid = fl6->fl6_gre_key;
1622         keys->tags.flow_label = (__force u32)flowi6_get_flowlabel(fl6);
1623         keys->basic.ip_proto = fl6->flowi6_proto;
1624 
1625         return flow_hash_from_keys(keys);
1626 }
1627 EXPORT_SYMBOL(__get_hash_from_flowi6);
1628 
1629 static const struct flow_dissector_key flow_keys_dissector_keys[] = {
1630         {
1631                 .key_id = FLOW_DISSECTOR_KEY_CONTROL,
1632                 .offset = offsetof(struct flow_keys, control),
1633         },
1634         {
1635                 .key_id = FLOW_DISSECTOR_KEY_BASIC,
1636                 .offset = offsetof(struct flow_keys, basic),
1637         },
1638         {
1639                 .key_id = FLOW_DISSECTOR_KEY_IPV4_ADDRS,
1640                 .offset = offsetof(struct flow_keys, addrs.v4addrs),
1641         },
1642         {
1643                 .key_id = FLOW_DISSECTOR_KEY_IPV6_ADDRS,
1644                 .offset = offsetof(struct flow_keys, addrs.v6addrs),
1645         },
1646         {
1647                 .key_id = FLOW_DISSECTOR_KEY_TIPC,
1648                 .offset = offsetof(struct flow_keys, addrs.tipckey),
1649         },
1650         {
1651                 .key_id = FLOW_DISSECTOR_KEY_PORTS,
1652                 .offset = offsetof(struct flow_keys, ports),
1653         },
1654         {
1655                 .key_id = FLOW_DISSECTOR_KEY_VLAN,
1656                 .offset = offsetof(struct flow_keys, vlan),
1657         },
1658         {
1659                 .key_id = FLOW_DISSECTOR_KEY_FLOW_LABEL,
1660                 .offset = offsetof(struct flow_keys, tags),
1661         },
1662         {
1663                 .key_id = FLOW_DISSECTOR_KEY_GRE_KEYID,
1664                 .offset = offsetof(struct flow_keys, keyid),
1665         },
1666 };
1667 
1668 static const struct flow_dissector_key flow_keys_dissector_symmetric_keys[] = {
1669         {
1670                 .key_id = FLOW_DISSECTOR_KEY_CONTROL,
1671                 .offset = offsetof(struct flow_keys, control),
1672         },
1673         {
1674                 .key_id = FLOW_DISSECTOR_KEY_BASIC,
1675                 .offset = offsetof(struct flow_keys, basic),
1676         },
1677         {
1678                 .key_id = FLOW_DISSECTOR_KEY_IPV4_ADDRS,
1679                 .offset = offsetof(struct flow_keys, addrs.v4addrs),
1680         },
1681         {
1682                 .key_id = FLOW_DISSECTOR_KEY_IPV6_ADDRS,
1683                 .offset = offsetof(struct flow_keys, addrs.v6addrs),
1684         },
1685         {
1686                 .key_id = FLOW_DISSECTOR_KEY_PORTS,
1687                 .offset = offsetof(struct flow_keys, ports),
1688         },
1689 };
1690 
1691 static const struct flow_dissector_key flow_keys_basic_dissector_keys[] = {
1692         {
1693                 .key_id = FLOW_DISSECTOR_KEY_CONTROL,
1694                 .offset = offsetof(struct flow_keys, control),
1695         },
1696         {
1697                 .key_id = FLOW_DISSECTOR_KEY_BASIC,
1698                 .offset = offsetof(struct flow_keys, basic),
1699         },
1700 };
1701 
1702 struct flow_dissector flow_keys_dissector __read_mostly;
1703 EXPORT_SYMBOL(flow_keys_dissector);
1704 
1705 struct flow_dissector flow_keys_basic_dissector __read_mostly;
1706 EXPORT_SYMBOL(flow_keys_basic_dissector);
1707 
1708 static int __init init_default_flow_dissectors(void)
1709 {
1710         skb_flow_dissector_init(&flow_keys_dissector,
1711                                 flow_keys_dissector_keys,
1712                                 ARRAY_SIZE(flow_keys_dissector_keys));
1713         skb_flow_dissector_init(&flow_keys_dissector_symmetric,
1714                                 flow_keys_dissector_symmetric_keys,
1715                                 ARRAY_SIZE(flow_keys_dissector_symmetric_keys));
1716         skb_flow_dissector_init(&flow_keys_basic_dissector,
1717                                 flow_keys_basic_dissector_keys,
1718                                 ARRAY_SIZE(flow_keys_basic_dissector_keys));
1719         return 0;
1720 }
1721 
1722 core_initcall(init_default_flow_dissectors);
1723 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp