ip6_fib.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Linux INET6 implementation
  4. *
  5. * Authors:
  6. * Pedro Roque <roque@di.fc.ul.pt>
  7. */
  8. #ifndef _IP6_FIB_H
  9. #define _IP6_FIB_H
  10. #include <linux/ipv6_route.h>
  11. #include <linux/rtnetlink.h>
  12. #include <linux/spinlock.h>
  13. #include <linux/notifier.h>
  14. #include <net/dst.h>
  15. #include <net/flow.h>
  16. #include <net/ip_fib.h>
  17. #include <net/netlink.h>
  18. #include <net/inetpeer.h>
  19. #include <net/fib_notifier.h>
  20. #include <linux/indirect_call_wrapper.h>
  21. #include <uapi/linux/bpf.h>
  22. #ifdef CONFIG_IPV6_MULTIPLE_TABLES
  23. #define FIB6_TABLE_HASHSZ 256
  24. #else
  25. #define FIB6_TABLE_HASHSZ 1
  26. #endif
  27. #define RT6_DEBUG 2
  28. struct rt6_info;
  29. struct fib6_info;
  30. struct fib6_config {
  31. u32 fc_table;
  32. u32 fc_metric;
  33. int fc_dst_len;
  34. int fc_src_len;
  35. int fc_ifindex;
  36. u32 fc_flags;
  37. u32 fc_protocol;
  38. u16 fc_type; /* only 8 bits are used */
  39. u16 fc_delete_all_nh : 1,
  40. fc_ignore_dev_down:1,
  41. __unused : 14;
  42. u32 fc_nh_id;
  43. struct in6_addr fc_dst;
  44. struct in6_addr fc_src;
  45. struct in6_addr fc_prefsrc;
  46. struct in6_addr fc_gateway;
  47. unsigned long fc_expires;
  48. struct nlattr *fc_mx;
  49. int fc_mx_len;
  50. int fc_mp_len;
  51. struct nlattr *fc_mp;
  52. struct nl_info fc_nlinfo;
  53. struct nlattr *fc_encap;
  54. u16 fc_encap_type;
  55. bool fc_is_fdb;
  56. };
  57. struct fib6_node {
  58. struct fib6_node __rcu *parent;
  59. struct fib6_node __rcu *left;
  60. struct fib6_node __rcu *right;
  61. #ifdef CONFIG_IPV6_SUBTREES
  62. struct fib6_node __rcu *subtree;
  63. #endif
  64. struct fib6_info __rcu *leaf;
  65. __u16 fn_bit; /* bit key */
  66. __u16 fn_flags;
  67. int fn_sernum;
  68. struct fib6_info __rcu *rr_ptr;
  69. struct rcu_head rcu;
  70. };
  71. struct fib6_gc_args {
  72. int timeout;
  73. int more;
  74. };
  75. #ifndef CONFIG_IPV6_SUBTREES
  76. #define FIB6_SUBTREE(fn) NULL
  77. static inline bool fib6_routes_require_src(const struct net *net)
  78. {
  79. return false;
  80. }
  81. static inline void fib6_routes_require_src_inc(struct net *net) {}
  82. static inline void fib6_routes_require_src_dec(struct net *net) {}
  83. #else
  84. static inline bool fib6_routes_require_src(const struct net *net)
  85. {
  86. return net->ipv6.fib6_routes_require_src > 0;
  87. }
  88. static inline void fib6_routes_require_src_inc(struct net *net)
  89. {
  90. net->ipv6.fib6_routes_require_src++;
  91. }
  92. static inline void fib6_routes_require_src_dec(struct net *net)
  93. {
  94. net->ipv6.fib6_routes_require_src--;
  95. }
  96. #define FIB6_SUBTREE(fn) (rcu_dereference_protected((fn)->subtree, 1))
  97. #endif
  98. /*
  99. * routing information
  100. *
  101. */
  102. struct rt6key {
  103. struct in6_addr addr;
  104. int plen;
  105. };
  106. struct fib6_table;
  107. struct rt6_exception_bucket {
  108. struct hlist_head chain;
  109. int depth;
  110. };
  111. struct rt6_exception {
  112. struct hlist_node hlist;
  113. struct rt6_info *rt6i;
  114. unsigned long stamp;
  115. struct rcu_head rcu;
  116. };
  117. #define FIB6_EXCEPTION_BUCKET_SIZE_SHIFT 10
  118. #define FIB6_EXCEPTION_BUCKET_SIZE (1 << FIB6_EXCEPTION_BUCKET_SIZE_SHIFT)
  119. #define FIB6_MAX_DEPTH 5
  120. struct fib6_nh {
  121. struct fib_nh_common nh_common;
  122. #ifdef CONFIG_IPV6_ROUTER_PREF
  123. unsigned long last_probe;
  124. #endif
  125. struct rt6_info * __percpu *rt6i_pcpu;
  126. struct rt6_exception_bucket __rcu *rt6i_exception_bucket;
  127. };
  128. struct fib6_info {
  129. struct fib6_table *fib6_table;
  130. struct fib6_info __rcu *fib6_next;
  131. struct fib6_node __rcu *fib6_node;
  132. /* Multipath routes:
  133. * siblings is a list of fib6_info that have the same metric/weight,
  134. * destination, but not the same gateway. nsiblings is just a cache
  135. * to speed up lookup.
  136. */
  137. union {
  138. struct list_head fib6_siblings;
  139. struct list_head nh_list;
  140. };
  141. unsigned int fib6_nsiblings;
  142. refcount_t fib6_ref;
  143. unsigned long expires;
  144. struct hlist_node gc_link;
  145. struct dst_metrics *fib6_metrics;
  146. #define fib6_pmtu fib6_metrics->metrics[RTAX_MTU-1]
  147. struct rt6key fib6_dst;
  148. u32 fib6_flags;
  149. struct rt6key fib6_src;
  150. struct rt6key fib6_prefsrc;
  151. u32 fib6_metric;
  152. u8 fib6_protocol;
  153. u8 fib6_type;
  154. u8 offload;
  155. u8 trap;
  156. u8 offload_failed;
  157. u8 should_flush:1,
  158. dst_nocount:1,
  159. dst_nopolicy:1,
  160. fib6_destroying:1,
  161. unused:4;
  162. struct rcu_head rcu;
  163. struct nexthop *nh;
  164. struct fib6_nh fib6_nh[];
  165. };
  166. struct rt6_info {
  167. struct dst_entry dst;
  168. struct fib6_info __rcu *from;
  169. int sernum;
  170. struct rt6key rt6i_dst;
  171. struct rt6key rt6i_src;
  172. struct in6_addr rt6i_gateway;
  173. struct inet6_dev *rt6i_idev;
  174. u32 rt6i_flags;
  175. /* more non-fragment space at head required */
  176. unsigned short rt6i_nfheader_len;
  177. };
  178. struct fib6_result {
  179. struct fib6_nh *nh;
  180. struct fib6_info *f6i;
  181. u32 fib6_flags;
  182. u8 fib6_type;
  183. struct rt6_info *rt6;
  184. };
  185. #define for_each_fib6_node_rt_rcu(fn) \
  186. for (rt = rcu_dereference((fn)->leaf); rt; \
  187. rt = rcu_dereference(rt->fib6_next))
  188. #define for_each_fib6_walker_rt(w) \
  189. for (rt = (w)->leaf; rt; \
  190. rt = rcu_dereference_protected(rt->fib6_next, 1))
  191. #define dst_rt6_info(_ptr) container_of_const(_ptr, struct rt6_info, dst)
  192. static inline struct inet6_dev *ip6_dst_idev(const struct dst_entry *dst)
  193. {
  194. return dst_rt6_info(dst)->rt6i_idev;
  195. }
  196. static inline bool fib6_requires_src(const struct fib6_info *rt)
  197. {
  198. return rt->fib6_src.plen > 0;
  199. }
  200. /* The callers should hold f6i->fib6_table->tb6_lock if a route has ever
  201. * been added to a table before.
  202. */
  203. static inline void fib6_clean_expires(struct fib6_info *f6i)
  204. {
  205. f6i->fib6_flags &= ~RTF_EXPIRES;
  206. f6i->expires = 0;
  207. }
  208. /* The callers should hold f6i->fib6_table->tb6_lock if a route has ever
  209. * been added to a table before.
  210. */
  211. static inline void fib6_set_expires(struct fib6_info *f6i,
  212. unsigned long expires)
  213. {
  214. f6i->expires = expires;
  215. f6i->fib6_flags |= RTF_EXPIRES;
  216. }
  217. static inline bool fib6_check_expired(const struct fib6_info *f6i)
  218. {
  219. if (f6i->fib6_flags & RTF_EXPIRES)
  220. return time_after(jiffies, f6i->expires);
  221. return false;
  222. }
  223. /* Function to safely get fn->fn_sernum for passed in rt
  224. * and store result in passed in cookie.
  225. * Return true if we can get cookie safely
  226. * Return false if not
  227. */
  228. static inline bool fib6_get_cookie_safe(const struct fib6_info *f6i,
  229. u32 *cookie)
  230. {
  231. struct fib6_node *fn;
  232. bool status = false;
  233. fn = rcu_dereference(f6i->fib6_node);
  234. if (fn) {
  235. *cookie = READ_ONCE(fn->fn_sernum);
  236. /* pairs with smp_wmb() in __fib6_update_sernum_upto_root() */
  237. smp_rmb();
  238. status = true;
  239. }
  240. return status;
  241. }
  242. static inline u32 rt6_get_cookie(const struct rt6_info *rt)
  243. {
  244. struct fib6_info *from;
  245. u32 cookie = 0;
  246. if (rt->sernum)
  247. return rt->sernum;
  248. rcu_read_lock();
  249. from = rcu_dereference(rt->from);
  250. if (from)
  251. fib6_get_cookie_safe(from, &cookie);
  252. rcu_read_unlock();
  253. return cookie;
  254. }
  255. static inline void ip6_rt_put(struct rt6_info *rt)
  256. {
  257. /* dst_release() accepts a NULL parameter.
  258. * We rely on dst being first structure in struct rt6_info
  259. */
  260. BUILD_BUG_ON(offsetof(struct rt6_info, dst) != 0);
  261. dst_release(&rt->dst);
  262. }
  263. struct fib6_info *fib6_info_alloc(gfp_t gfp_flags, bool with_fib6_nh);
  264. void fib6_info_destroy_rcu(struct rcu_head *head);
  265. static inline void fib6_info_hold(struct fib6_info *f6i)
  266. {
  267. refcount_inc(&f6i->fib6_ref);
  268. }
  269. static inline bool fib6_info_hold_safe(struct fib6_info *f6i)
  270. {
  271. return refcount_inc_not_zero(&f6i->fib6_ref);
  272. }
  273. static inline void fib6_info_release(struct fib6_info *f6i)
  274. {
  275. if (f6i && refcount_dec_and_test(&f6i->fib6_ref)) {
  276. DEBUG_NET_WARN_ON_ONCE(!hlist_unhashed(&f6i->gc_link));
  277. call_rcu_hurry(&f6i->rcu, fib6_info_destroy_rcu);
  278. }
  279. }
  280. enum fib6_walk_state {
  281. #ifdef CONFIG_IPV6_SUBTREES
  282. FWS_S,
  283. #endif
  284. FWS_L,
  285. FWS_R,
  286. FWS_C,
  287. FWS_U
  288. };
  289. struct fib6_walker {
  290. struct list_head lh;
  291. struct fib6_node *root, *node;
  292. struct fib6_info *leaf;
  293. enum fib6_walk_state state;
  294. unsigned int skip;
  295. unsigned int count;
  296. unsigned int skip_in_node;
  297. int (*func)(struct fib6_walker *);
  298. void *args;
  299. };
  300. struct rt6_statistics {
  301. __u32 fib_nodes; /* all fib6 nodes */
  302. __u32 fib_route_nodes; /* intermediate nodes */
  303. __u32 fib_rt_entries; /* rt entries in fib table */
  304. __u32 fib_rt_cache; /* cached rt entries in exception table */
  305. __u32 fib_discarded_routes; /* total number of routes delete */
  306. /* The following stat is not protected by any lock */
  307. atomic_t fib_rt_alloc; /* total number of routes alloced */
  308. };
  309. #define RTN_TL_ROOT 0x0001
  310. #define RTN_ROOT 0x0002 /* tree root node */
  311. #define RTN_RTINFO 0x0004 /* node with valid routing info */
  312. /*
  313. * priority levels (or metrics)
  314. *
  315. */
  316. struct fib6_table {
  317. struct hlist_node tb6_hlist;
  318. u32 tb6_id;
  319. spinlock_t tb6_lock;
  320. struct fib6_node tb6_root;
  321. struct inet_peer_base tb6_peers;
  322. unsigned int flags;
  323. unsigned int fib_seq;
  324. struct hlist_head tb6_gc_hlist; /* GC candidates */
  325. #define RT6_TABLE_HAS_DFLT_ROUTER BIT(0)
  326. };
  327. #define RT6_TABLE_UNSPEC RT_TABLE_UNSPEC
  328. #define RT6_TABLE_MAIN RT_TABLE_MAIN
  329. #define RT6_TABLE_DFLT RT6_TABLE_MAIN
  330. #define RT6_TABLE_INFO RT6_TABLE_MAIN
  331. #define RT6_TABLE_PREFIX RT6_TABLE_MAIN
  332. #ifdef CONFIG_IPV6_MULTIPLE_TABLES
  333. #define FIB6_TABLE_MIN 1
  334. #define FIB6_TABLE_MAX RT_TABLE_MAX
  335. #define RT6_TABLE_LOCAL RT_TABLE_LOCAL
  336. #else
  337. #define FIB6_TABLE_MIN RT_TABLE_MAIN
  338. #define FIB6_TABLE_MAX FIB6_TABLE_MIN
  339. #define RT6_TABLE_LOCAL RT6_TABLE_MAIN
  340. #endif
  341. typedef struct rt6_info *(*pol_lookup_t)(struct net *,
  342. struct fib6_table *,
  343. struct flowi6 *,
  344. const struct sk_buff *, int);
  345. struct fib6_entry_notifier_info {
  346. struct fib_notifier_info info; /* must be first */
  347. struct fib6_info *rt;
  348. unsigned int nsiblings;
  349. };
  350. /*
  351. * exported functions
  352. */
  353. struct fib6_table *fib6_get_table(struct net *net, u32 id);
  354. struct fib6_table *fib6_new_table(struct net *net, u32 id);
  355. struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
  356. const struct sk_buff *skb,
  357. int flags, pol_lookup_t lookup);
  358. /* called with rcu lock held; can return error pointer
  359. * caller needs to select path
  360. */
  361. int fib6_lookup(struct net *net, int oif, struct flowi6 *fl6,
  362. struct fib6_result *res, int flags);
  363. /* called with rcu lock held; caller needs to select path */
  364. int fib6_table_lookup(struct net *net, struct fib6_table *table,
  365. int oif, struct flowi6 *fl6, struct fib6_result *res,
  366. int strict);
  367. void fib6_select_path(const struct net *net, struct fib6_result *res,
  368. struct flowi6 *fl6, int oif, bool have_oif_match,
  369. const struct sk_buff *skb, int strict);
  370. struct fib6_node *fib6_node_lookup(struct fib6_node *root,
  371. const struct in6_addr *daddr,
  372. const struct in6_addr *saddr);
  373. struct fib6_node *fib6_locate(struct fib6_node *root,
  374. const struct in6_addr *daddr, int dst_len,
  375. const struct in6_addr *saddr, int src_len,
  376. bool exact_match);
  377. void fib6_clean_all(struct net *net, int (*func)(struct fib6_info *, void *arg),
  378. void *arg);
  379. void fib6_clean_all_skip_notify(struct net *net,
  380. int (*func)(struct fib6_info *, void *arg),
  381. void *arg);
  382. int fib6_add(struct fib6_node *root, struct fib6_info *rt,
  383. struct nl_info *info, struct netlink_ext_ack *extack);
  384. int fib6_del(struct fib6_info *rt, struct nl_info *info);
  385. static inline
  386. void rt6_get_prefsrc(const struct rt6_info *rt, struct in6_addr *addr)
  387. {
  388. const struct fib6_info *from;
  389. rcu_read_lock();
  390. from = rcu_dereference(rt->from);
  391. if (from)
  392. *addr = from->fib6_prefsrc.addr;
  393. else
  394. *addr = in6addr_any;
  395. rcu_read_unlock();
  396. }
  397. int fib6_nh_init(struct net *net, struct fib6_nh *fib6_nh,
  398. struct fib6_config *cfg, gfp_t gfp_flags,
  399. struct netlink_ext_ack *extack);
  400. void fib6_nh_release(struct fib6_nh *fib6_nh);
  401. void fib6_nh_release_dsts(struct fib6_nh *fib6_nh);
  402. int call_fib6_entry_notifiers(struct net *net,
  403. enum fib_event_type event_type,
  404. struct fib6_info *rt,
  405. struct netlink_ext_ack *extack);
  406. int call_fib6_multipath_entry_notifiers(struct net *net,
  407. enum fib_event_type event_type,
  408. struct fib6_info *rt,
  409. unsigned int nsiblings,
  410. struct netlink_ext_ack *extack);
  411. int call_fib6_entry_notifiers_replace(struct net *net, struct fib6_info *rt);
  412. void fib6_rt_update(struct net *net, struct fib6_info *rt,
  413. struct nl_info *info);
  414. void inet6_rt_notify(int event, struct fib6_info *rt, struct nl_info *info,
  415. unsigned int flags);
  416. void fib6_run_gc(unsigned long expires, struct net *net, bool force);
  417. void fib6_gc_cleanup(void);
  418. int fib6_init(void);
  419. /* Add the route to the gc list if it is not already there
  420. *
  421. * The callers should hold f6i->fib6_table->tb6_lock.
  422. */
  423. static inline void fib6_add_gc_list(struct fib6_info *f6i)
  424. {
  425. /* If fib6_node is null, the f6i is not in (or removed from) the
  426. * table.
  427. *
  428. * There is a gap between finding the f6i from the table and
  429. * calling this function without the protection of the tb6_lock.
  430. * This check makes sure the f6i is not added to the gc list when
  431. * it is not on the table.
  432. */
  433. if (!rcu_dereference_protected(f6i->fib6_node,
  434. lockdep_is_held(&f6i->fib6_table->tb6_lock)))
  435. return;
  436. if (hlist_unhashed(&f6i->gc_link))
  437. hlist_add_head(&f6i->gc_link, &f6i->fib6_table->tb6_gc_hlist);
  438. }
  439. /* Remove the route from the gc list if it is on the list.
  440. *
  441. * The callers should hold f6i->fib6_table->tb6_lock.
  442. */
  443. static inline void fib6_remove_gc_list(struct fib6_info *f6i)
  444. {
  445. if (!hlist_unhashed(&f6i->gc_link))
  446. hlist_del_init(&f6i->gc_link);
  447. }
  448. struct ipv6_route_iter {
  449. struct seq_net_private p;
  450. struct fib6_walker w;
  451. loff_t skip;
  452. struct fib6_table *tbl;
  453. int sernum;
  454. };
  455. extern const struct seq_operations ipv6_route_seq_ops;
  456. int call_fib6_notifier(struct notifier_block *nb,
  457. enum fib_event_type event_type,
  458. struct fib_notifier_info *info);
  459. int call_fib6_notifiers(struct net *net, enum fib_event_type event_type,
  460. struct fib_notifier_info *info);
  461. int __net_init fib6_notifier_init(struct net *net);
  462. void __net_exit fib6_notifier_exit(struct net *net);
  463. unsigned int fib6_tables_seq_read(struct net *net);
  464. int fib6_tables_dump(struct net *net, struct notifier_block *nb,
  465. struct netlink_ext_ack *extack);
  466. void fib6_update_sernum(struct net *net, struct fib6_info *rt);
  467. void fib6_update_sernum_upto_root(struct net *net, struct fib6_info *rt);
  468. void fib6_update_sernum_stub(struct net *net, struct fib6_info *f6i);
  469. void fib6_metric_set(struct fib6_info *f6i, int metric, u32 val);
  470. static inline bool fib6_metric_locked(struct fib6_info *f6i, int metric)
  471. {
  472. return !!(f6i->fib6_metrics->metrics[RTAX_LOCK - 1] & (1 << metric));
  473. }
  474. void fib6_info_hw_flags_set(struct net *net, struct fib6_info *f6i,
  475. bool offload, bool trap, bool offload_failed);
  476. #if IS_BUILTIN(CONFIG_IPV6) && defined(CONFIG_BPF_SYSCALL)
  477. struct bpf_iter__ipv6_route {
  478. __bpf_md_ptr(struct bpf_iter_meta *, meta);
  479. __bpf_md_ptr(struct fib6_info *, rt);
  480. };
  481. #endif
  482. INDIRECT_CALLABLE_DECLARE(struct rt6_info *ip6_pol_route_output(struct net *net,
  483. struct fib6_table *table,
  484. struct flowi6 *fl6,
  485. const struct sk_buff *skb,
  486. int flags));
  487. INDIRECT_CALLABLE_DECLARE(struct rt6_info *ip6_pol_route_input(struct net *net,
  488. struct fib6_table *table,
  489. struct flowi6 *fl6,
  490. const struct sk_buff *skb,
  491. int flags));
  492. INDIRECT_CALLABLE_DECLARE(struct rt6_info *__ip6_route_redirect(struct net *net,
  493. struct fib6_table *table,
  494. struct flowi6 *fl6,
  495. const struct sk_buff *skb,
  496. int flags));
  497. INDIRECT_CALLABLE_DECLARE(struct rt6_info *ip6_pol_route_lookup(struct net *net,
  498. struct fib6_table *table,
  499. struct flowi6 *fl6,
  500. const struct sk_buff *skb,
  501. int flags));
  502. static inline struct rt6_info *pol_lookup_func(pol_lookup_t lookup,
  503. struct net *net,
  504. struct fib6_table *table,
  505. struct flowi6 *fl6,
  506. const struct sk_buff *skb,
  507. int flags)
  508. {
  509. return INDIRECT_CALL_4(lookup,
  510. ip6_pol_route_output,
  511. ip6_pol_route_input,
  512. ip6_pol_route_lookup,
  513. __ip6_route_redirect,
  514. net, table, fl6, skb, flags);
  515. }
  516. #ifdef CONFIG_IPV6_MULTIPLE_TABLES
  517. static inline bool fib6_has_custom_rules(const struct net *net)
  518. {
  519. return net->ipv6.fib6_has_custom_rules;
  520. }
  521. int fib6_rules_init(void);
  522. void fib6_rules_cleanup(void);
  523. bool fib6_rule_default(const struct fib_rule *rule);
  524. int fib6_rules_dump(struct net *net, struct notifier_block *nb,
  525. struct netlink_ext_ack *extack);
  526. unsigned int fib6_rules_seq_read(struct net *net);
  527. static inline bool fib6_rules_early_flow_dissect(struct net *net,
  528. struct sk_buff *skb,
  529. struct flowi6 *fl6,
  530. struct flow_keys *flkeys)
  531. {
  532. unsigned int flag = FLOW_DISSECTOR_F_STOP_AT_ENCAP;
  533. if (!net->ipv6.fib6_rules_require_fldissect)
  534. return false;
  535. memset(flkeys, 0, sizeof(*flkeys));
  536. __skb_flow_dissect(net, skb, &flow_keys_dissector,
  537. flkeys, NULL, 0, 0, 0, flag);
  538. fl6->fl6_sport = flkeys->ports.src;
  539. fl6->fl6_dport = flkeys->ports.dst;
  540. fl6->flowi6_proto = flkeys->basic.ip_proto;
  541. return true;
  542. }
  543. #else
  544. static inline bool fib6_has_custom_rules(const struct net *net)
  545. {
  546. return false;
  547. }
  548. static inline int fib6_rules_init(void)
  549. {
  550. return 0;
  551. }
  552. static inline void fib6_rules_cleanup(void)
  553. {
  554. return ;
  555. }
  556. static inline bool fib6_rule_default(const struct fib_rule *rule)
  557. {
  558. return true;
  559. }
  560. static inline int fib6_rules_dump(struct net *net, struct notifier_block *nb,
  561. struct netlink_ext_ack *extack)
  562. {
  563. return 0;
  564. }
  565. static inline unsigned int fib6_rules_seq_read(struct net *net)
  566. {
  567. return 0;
  568. }
  569. static inline bool fib6_rules_early_flow_dissect(struct net *net,
  570. struct sk_buff *skb,
  571. struct flowi6 *fl6,
  572. struct flow_keys *flkeys)
  573. {
  574. return false;
  575. }
  576. #endif
  577. #endif