ip_fib.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * INET An implementation of the TCP/IP protocol suite for the LINUX
  4. * operating system. INET is implemented using the BSD Socket
  5. * interface as the means of communication with the user level.
  6. *
  7. * Definitions for the Forwarding Information Base.
  8. *
  9. * Authors: A.N.Kuznetsov, <[email protected]>
  10. */
  11. #ifndef _NET_IP_FIB_H
  12. #define _NET_IP_FIB_H
  13. #include <net/flow.h>
  14. #include <linux/seq_file.h>
  15. #include <linux/rcupdate.h>
  16. #include <net/fib_notifier.h>
  17. #include <net/fib_rules.h>
  18. #include <net/inet_dscp.h>
  19. #include <net/inetpeer.h>
  20. #include <linux/percpu.h>
  21. #include <linux/notifier.h>
  22. #include <linux/refcount.h>
  23. struct fib_config {
  24. u8 fc_dst_len;
  25. dscp_t fc_dscp;
  26. u8 fc_protocol;
  27. u8 fc_scope;
  28. u8 fc_type;
  29. u8 fc_gw_family;
  30. /* 2 bytes unused */
  31. u32 fc_table;
  32. __be32 fc_dst;
  33. union {
  34. __be32 fc_gw4;
  35. struct in6_addr fc_gw6;
  36. };
  37. int fc_oif;
  38. u32 fc_flags;
  39. u32 fc_priority;
  40. __be32 fc_prefsrc;
  41. u32 fc_nh_id;
  42. struct nlattr *fc_mx;
  43. struct rtnexthop *fc_mp;
  44. int fc_mx_len;
  45. int fc_mp_len;
  46. u32 fc_flow;
  47. u32 fc_nlflags;
  48. struct nl_info fc_nlinfo;
  49. struct nlattr *fc_encap;
  50. u16 fc_encap_type;
  51. };
  52. struct fib_info;
  53. struct rtable;
  54. struct fib_nh_exception {
  55. struct fib_nh_exception __rcu *fnhe_next;
  56. int fnhe_genid;
  57. __be32 fnhe_daddr;
  58. u32 fnhe_pmtu;
  59. bool fnhe_mtu_locked;
  60. __be32 fnhe_gw;
  61. unsigned long fnhe_expires;
  62. struct rtable __rcu *fnhe_rth_input;
  63. struct rtable __rcu *fnhe_rth_output;
  64. unsigned long fnhe_stamp;
  65. struct rcu_head rcu;
  66. };
  67. struct fnhe_hash_bucket {
  68. struct fib_nh_exception __rcu *chain;
  69. };
  70. #define FNHE_HASH_SHIFT 11
  71. #define FNHE_HASH_SIZE (1 << FNHE_HASH_SHIFT)
  72. #define FNHE_RECLAIM_DEPTH 5
  73. struct fib_nh_common {
  74. struct net_device *nhc_dev;
  75. netdevice_tracker nhc_dev_tracker;
  76. int nhc_oif;
  77. unsigned char nhc_scope;
  78. u8 nhc_family;
  79. u8 nhc_gw_family;
  80. unsigned char nhc_flags;
  81. struct lwtunnel_state *nhc_lwtstate;
  82. union {
  83. __be32 ipv4;
  84. struct in6_addr ipv6;
  85. } nhc_gw;
  86. int nhc_weight;
  87. atomic_t nhc_upper_bound;
  88. /* v4 specific, but allows fib6_nh with v4 routes */
  89. struct rtable __rcu * __percpu *nhc_pcpu_rth_output;
  90. struct rtable __rcu *nhc_rth_input;
  91. struct fnhe_hash_bucket __rcu *nhc_exceptions;
  92. };
  93. struct fib_nh {
  94. struct fib_nh_common nh_common;
  95. struct hlist_node nh_hash;
  96. struct fib_info *nh_parent;
  97. #ifdef CONFIG_IP_ROUTE_CLASSID
  98. __u32 nh_tclassid;
  99. #endif
  100. __be32 nh_saddr;
  101. int nh_saddr_genid;
  102. #define fib_nh_family nh_common.nhc_family
  103. #define fib_nh_dev nh_common.nhc_dev
  104. #define fib_nh_dev_tracker nh_common.nhc_dev_tracker
  105. #define fib_nh_oif nh_common.nhc_oif
  106. #define fib_nh_flags nh_common.nhc_flags
  107. #define fib_nh_lws nh_common.nhc_lwtstate
  108. #define fib_nh_scope nh_common.nhc_scope
  109. #define fib_nh_gw_family nh_common.nhc_gw_family
  110. #define fib_nh_gw4 nh_common.nhc_gw.ipv4
  111. #define fib_nh_gw6 nh_common.nhc_gw.ipv6
  112. #define fib_nh_weight nh_common.nhc_weight
  113. #define fib_nh_upper_bound nh_common.nhc_upper_bound
  114. };
  115. /*
  116. * This structure contains data shared by many of routes.
  117. */
  118. struct nexthop;
  119. struct fib_info {
  120. struct hlist_node fib_hash;
  121. struct hlist_node fib_lhash;
  122. struct list_head nh_list;
  123. struct net *fib_net;
  124. refcount_t fib_treeref;
  125. refcount_t fib_clntref;
  126. unsigned int fib_flags;
  127. unsigned char fib_dead;
  128. unsigned char fib_protocol;
  129. unsigned char fib_scope;
  130. unsigned char fib_type;
  131. __be32 fib_prefsrc;
  132. u32 fib_tb_id;
  133. u32 fib_priority;
  134. struct dst_metrics *fib_metrics;
  135. #define fib_mtu fib_metrics->metrics[RTAX_MTU-1]
  136. #define fib_window fib_metrics->metrics[RTAX_WINDOW-1]
  137. #define fib_rtt fib_metrics->metrics[RTAX_RTT-1]
  138. #define fib_advmss fib_metrics->metrics[RTAX_ADVMSS-1]
  139. int fib_nhs;
  140. bool fib_nh_is_v6;
  141. bool nh_updated;
  142. struct nexthop *nh;
  143. struct rcu_head rcu;
  144. struct fib_nh fib_nh[];
  145. };
  146. #ifdef CONFIG_IP_MULTIPLE_TABLES
  147. struct fib_rule;
  148. #endif
  149. struct fib_table;
  150. struct fib_result {
  151. __be32 prefix;
  152. unsigned char prefixlen;
  153. unsigned char nh_sel;
  154. unsigned char type;
  155. unsigned char scope;
  156. u32 tclassid;
  157. struct fib_nh_common *nhc;
  158. struct fib_info *fi;
  159. struct fib_table *table;
  160. struct hlist_head *fa_head;
  161. };
  162. struct fib_result_nl {
  163. __be32 fl_addr; /* To be looked up*/
  164. u32 fl_mark;
  165. unsigned char fl_tos;
  166. unsigned char fl_scope;
  167. unsigned char tb_id_in;
  168. unsigned char tb_id; /* Results */
  169. unsigned char prefixlen;
  170. unsigned char nh_sel;
  171. unsigned char type;
  172. unsigned char scope;
  173. int err;
  174. };
  175. #ifdef CONFIG_IP_MULTIPLE_TABLES
  176. #define FIB_TABLE_HASHSZ 256
  177. #else
  178. #define FIB_TABLE_HASHSZ 2
  179. #endif
  180. __be32 fib_info_update_nhc_saddr(struct net *net, struct fib_nh_common *nhc,
  181. unsigned char scope);
  182. __be32 fib_result_prefsrc(struct net *net, struct fib_result *res);
  183. #define FIB_RES_NHC(res) ((res).nhc)
  184. #define FIB_RES_DEV(res) (FIB_RES_NHC(res)->nhc_dev)
  185. #define FIB_RES_OIF(res) (FIB_RES_NHC(res)->nhc_oif)
  186. struct fib_rt_info {
  187. struct fib_info *fi;
  188. u32 tb_id;
  189. __be32 dst;
  190. int dst_len;
  191. dscp_t dscp;
  192. u8 type;
  193. u8 offload:1,
  194. trap:1,
  195. offload_failed:1,
  196. unused:5;
  197. };
  198. struct fib_entry_notifier_info {
  199. struct fib_notifier_info info; /* must be first */
  200. u32 dst;
  201. int dst_len;
  202. struct fib_info *fi;
  203. dscp_t dscp;
  204. u8 type;
  205. u32 tb_id;
  206. };
  207. struct fib_nh_notifier_info {
  208. struct fib_notifier_info info; /* must be first */
  209. struct fib_nh *fib_nh;
  210. };
  211. int call_fib4_notifier(struct notifier_block *nb,
  212. enum fib_event_type event_type,
  213. struct fib_notifier_info *info);
  214. int call_fib4_notifiers(struct net *net, enum fib_event_type event_type,
  215. struct fib_notifier_info *info);
  216. int __net_init fib4_notifier_init(struct net *net);
  217. void __net_exit fib4_notifier_exit(struct net *net);
  218. void fib_info_notify_update(struct net *net, struct nl_info *info);
  219. int fib_notify(struct net *net, struct notifier_block *nb,
  220. struct netlink_ext_ack *extack);
  221. struct fib_table {
  222. struct hlist_node tb_hlist;
  223. u32 tb_id;
  224. int tb_num_default;
  225. struct rcu_head rcu;
  226. unsigned long *tb_data;
  227. unsigned long __data[];
  228. };
  229. struct fib_dump_filter {
  230. u32 table_id;
  231. /* filter_set is an optimization that an entry is set */
  232. bool filter_set;
  233. bool dump_routes;
  234. bool dump_exceptions;
  235. unsigned char protocol;
  236. unsigned char rt_type;
  237. unsigned int flags;
  238. struct net_device *dev;
  239. };
  240. int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
  241. struct fib_result *res, int fib_flags);
  242. int fib_table_insert(struct net *, struct fib_table *, struct fib_config *,
  243. struct netlink_ext_ack *extack);
  244. int fib_table_delete(struct net *, struct fib_table *, struct fib_config *,
  245. struct netlink_ext_ack *extack);
  246. int fib_table_dump(struct fib_table *table, struct sk_buff *skb,
  247. struct netlink_callback *cb, struct fib_dump_filter *filter);
  248. int fib_table_flush(struct net *net, struct fib_table *table, bool flush_all);
  249. struct fib_table *fib_trie_unmerge(struct fib_table *main_tb);
  250. void fib_table_flush_external(struct fib_table *table);
  251. void fib_free_table(struct fib_table *tb);
  252. #ifndef CONFIG_IP_MULTIPLE_TABLES
  253. #define TABLE_LOCAL_INDEX (RT_TABLE_LOCAL & (FIB_TABLE_HASHSZ - 1))
  254. #define TABLE_MAIN_INDEX (RT_TABLE_MAIN & (FIB_TABLE_HASHSZ - 1))
  255. static inline struct fib_table *fib_get_table(struct net *net, u32 id)
  256. {
  257. struct hlist_node *tb_hlist;
  258. struct hlist_head *ptr;
  259. ptr = id == RT_TABLE_LOCAL ?
  260. &net->ipv4.fib_table_hash[TABLE_LOCAL_INDEX] :
  261. &net->ipv4.fib_table_hash[TABLE_MAIN_INDEX];
  262. tb_hlist = rcu_dereference_rtnl(hlist_first_rcu(ptr));
  263. return hlist_entry(tb_hlist, struct fib_table, tb_hlist);
  264. }
  265. static inline struct fib_table *fib_new_table(struct net *net, u32 id)
  266. {
  267. return fib_get_table(net, id);
  268. }
  269. static inline int fib_lookup(struct net *net, const struct flowi4 *flp,
  270. struct fib_result *res, unsigned int flags)
  271. {
  272. struct fib_table *tb;
  273. int err = -ENETUNREACH;
  274. rcu_read_lock();
  275. tb = fib_get_table(net, RT_TABLE_MAIN);
  276. if (tb)
  277. err = fib_table_lookup(tb, flp, res, flags | FIB_LOOKUP_NOREF);
  278. if (err == -EAGAIN)
  279. err = -ENETUNREACH;
  280. rcu_read_unlock();
  281. return err;
  282. }
  283. static inline bool fib4_has_custom_rules(const struct net *net)
  284. {
  285. return false;
  286. }
  287. static inline bool fib4_rule_default(const struct fib_rule *rule)
  288. {
  289. return true;
  290. }
  291. static inline int fib4_rules_dump(struct net *net, struct notifier_block *nb,
  292. struct netlink_ext_ack *extack)
  293. {
  294. return 0;
  295. }
  296. static inline unsigned int fib4_rules_seq_read(struct net *net)
  297. {
  298. return 0;
  299. }
  300. static inline bool fib4_rules_early_flow_dissect(struct net *net,
  301. struct sk_buff *skb,
  302. struct flowi4 *fl4,
  303. struct flow_keys *flkeys)
  304. {
  305. return false;
  306. }
  307. #else /* CONFIG_IP_MULTIPLE_TABLES */
  308. int __net_init fib4_rules_init(struct net *net);
  309. void __net_exit fib4_rules_exit(struct net *net);
  310. struct fib_table *fib_new_table(struct net *net, u32 id);
  311. struct fib_table *fib_get_table(struct net *net, u32 id);
  312. int __fib_lookup(struct net *net, struct flowi4 *flp,
  313. struct fib_result *res, unsigned int flags);
  314. static inline int fib_lookup(struct net *net, struct flowi4 *flp,
  315. struct fib_result *res, unsigned int flags)
  316. {
  317. struct fib_table *tb;
  318. int err = -ENETUNREACH;
  319. flags |= FIB_LOOKUP_NOREF;
  320. if (net->ipv4.fib_has_custom_rules)
  321. return __fib_lookup(net, flp, res, flags);
  322. rcu_read_lock();
  323. res->tclassid = 0;
  324. tb = rcu_dereference_rtnl(net->ipv4.fib_main);
  325. if (tb)
  326. err = fib_table_lookup(tb, flp, res, flags);
  327. if (!err)
  328. goto out;
  329. tb = rcu_dereference_rtnl(net->ipv4.fib_default);
  330. if (tb)
  331. err = fib_table_lookup(tb, flp, res, flags);
  332. out:
  333. if (err == -EAGAIN)
  334. err = -ENETUNREACH;
  335. rcu_read_unlock();
  336. return err;
  337. }
  338. static inline bool fib4_has_custom_rules(const struct net *net)
  339. {
  340. return net->ipv4.fib_has_custom_rules;
  341. }
  342. bool fib4_rule_default(const struct fib_rule *rule);
  343. int fib4_rules_dump(struct net *net, struct notifier_block *nb,
  344. struct netlink_ext_ack *extack);
  345. unsigned int fib4_rules_seq_read(struct net *net);
  346. static inline bool fib4_rules_early_flow_dissect(struct net *net,
  347. struct sk_buff *skb,
  348. struct flowi4 *fl4,
  349. struct flow_keys *flkeys)
  350. {
  351. unsigned int flag = FLOW_DISSECTOR_F_STOP_AT_ENCAP;
  352. if (!net->ipv4.fib_rules_require_fldissect)
  353. return false;
  354. memset(flkeys, 0, sizeof(*flkeys));
  355. __skb_flow_dissect(net, skb, &flow_keys_dissector,
  356. flkeys, NULL, 0, 0, 0, flag);
  357. fl4->fl4_sport = flkeys->ports.src;
  358. fl4->fl4_dport = flkeys->ports.dst;
  359. fl4->flowi4_proto = flkeys->basic.ip_proto;
  360. return true;
  361. }
  362. #endif /* CONFIG_IP_MULTIPLE_TABLES */
  363. /* Exported by fib_frontend.c */
  364. extern const struct nla_policy rtm_ipv4_policy[];
  365. void ip_fib_init(void);
  366. int fib_gw_from_via(struct fib_config *cfg, struct nlattr *nla,
  367. struct netlink_ext_ack *extack);
  368. __be32 fib_compute_spec_dst(struct sk_buff *skb);
  369. bool fib_info_nh_uses_dev(struct fib_info *fi, const struct net_device *dev);
  370. int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
  371. u8 tos, int oif, struct net_device *dev,
  372. struct in_device *idev, u32 *itag);
  373. #ifdef CONFIG_IP_ROUTE_CLASSID
  374. static inline int fib_num_tclassid_users(struct net *net)
  375. {
  376. return atomic_read(&net->ipv4.fib_num_tclassid_users);
  377. }
  378. #else
  379. static inline int fib_num_tclassid_users(struct net *net)
  380. {
  381. return 0;
  382. }
  383. #endif
  384. int fib_unmerge(struct net *net);
  385. static inline bool nhc_l3mdev_matches_dev(const struct fib_nh_common *nhc,
  386. const struct net_device *dev)
  387. {
  388. if (nhc->nhc_dev == dev ||
  389. l3mdev_master_ifindex_rcu(nhc->nhc_dev) == dev->ifindex)
  390. return true;
  391. return false;
  392. }
  393. /* Exported by fib_semantics.c */
  394. int ip_fib_check_default(__be32 gw, struct net_device *dev);
  395. int fib_sync_down_dev(struct net_device *dev, unsigned long event, bool force);
  396. int fib_sync_down_addr(struct net_device *dev, __be32 local);
  397. int fib_sync_up(struct net_device *dev, unsigned char nh_flags);
  398. void fib_sync_mtu(struct net_device *dev, u32 orig_mtu);
  399. void fib_nhc_update_mtu(struct fib_nh_common *nhc, u32 new, u32 orig);
  400. /* Fields used for sysctl_fib_multipath_hash_fields.
  401. * Common to IPv4 and IPv6.
  402. *
  403. * Add new fields at the end. This is user API.
  404. */
  405. #define FIB_MULTIPATH_HASH_FIELD_SRC_IP BIT(0)
  406. #define FIB_MULTIPATH_HASH_FIELD_DST_IP BIT(1)
  407. #define FIB_MULTIPATH_HASH_FIELD_IP_PROTO BIT(2)
  408. #define FIB_MULTIPATH_HASH_FIELD_FLOWLABEL BIT(3)
  409. #define FIB_MULTIPATH_HASH_FIELD_SRC_PORT BIT(4)
  410. #define FIB_MULTIPATH_HASH_FIELD_DST_PORT BIT(5)
  411. #define FIB_MULTIPATH_HASH_FIELD_INNER_SRC_IP BIT(6)
  412. #define FIB_MULTIPATH_HASH_FIELD_INNER_DST_IP BIT(7)
  413. #define FIB_MULTIPATH_HASH_FIELD_INNER_IP_PROTO BIT(8)
  414. #define FIB_MULTIPATH_HASH_FIELD_INNER_FLOWLABEL BIT(9)
  415. #define FIB_MULTIPATH_HASH_FIELD_INNER_SRC_PORT BIT(10)
  416. #define FIB_MULTIPATH_HASH_FIELD_INNER_DST_PORT BIT(11)
  417. #define FIB_MULTIPATH_HASH_FIELD_OUTER_MASK \
  418. (FIB_MULTIPATH_HASH_FIELD_SRC_IP | \
  419. FIB_MULTIPATH_HASH_FIELD_DST_IP | \
  420. FIB_MULTIPATH_HASH_FIELD_IP_PROTO | \
  421. FIB_MULTIPATH_HASH_FIELD_FLOWLABEL | \
  422. FIB_MULTIPATH_HASH_FIELD_SRC_PORT | \
  423. FIB_MULTIPATH_HASH_FIELD_DST_PORT)
  424. #define FIB_MULTIPATH_HASH_FIELD_INNER_MASK \
  425. (FIB_MULTIPATH_HASH_FIELD_INNER_SRC_IP | \
  426. FIB_MULTIPATH_HASH_FIELD_INNER_DST_IP | \
  427. FIB_MULTIPATH_HASH_FIELD_INNER_IP_PROTO | \
  428. FIB_MULTIPATH_HASH_FIELD_INNER_FLOWLABEL | \
  429. FIB_MULTIPATH_HASH_FIELD_INNER_SRC_PORT | \
  430. FIB_MULTIPATH_HASH_FIELD_INNER_DST_PORT)
  431. #define FIB_MULTIPATH_HASH_FIELD_ALL_MASK \
  432. (FIB_MULTIPATH_HASH_FIELD_OUTER_MASK | \
  433. FIB_MULTIPATH_HASH_FIELD_INNER_MASK)
  434. #define FIB_MULTIPATH_HASH_FIELD_DEFAULT_MASK \
  435. (FIB_MULTIPATH_HASH_FIELD_SRC_IP | \
  436. FIB_MULTIPATH_HASH_FIELD_DST_IP | \
  437. FIB_MULTIPATH_HASH_FIELD_IP_PROTO)
  438. #ifdef CONFIG_IP_ROUTE_MULTIPATH
  439. int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
  440. const struct sk_buff *skb, struct flow_keys *flkeys);
  441. #endif
  442. int fib_check_nh(struct net *net, struct fib_nh *nh, u32 table, u8 scope,
  443. struct netlink_ext_ack *extack);
  444. void fib_select_multipath(struct fib_result *res, int hash);
  445. void fib_select_path(struct net *net, struct fib_result *res,
  446. struct flowi4 *fl4, const struct sk_buff *skb);
  447. int fib_nh_init(struct net *net, struct fib_nh *fib_nh,
  448. struct fib_config *cfg, int nh_weight,
  449. struct netlink_ext_ack *extack);
  450. void fib_nh_release(struct net *net, struct fib_nh *fib_nh);
  451. int fib_nh_common_init(struct net *net, struct fib_nh_common *nhc,
  452. struct nlattr *fc_encap, u16 fc_encap_type,
  453. void *cfg, gfp_t gfp_flags,
  454. struct netlink_ext_ack *extack);
  455. void fib_nh_common_release(struct fib_nh_common *nhc);
  456. /* Exported by fib_trie.c */
  457. void fib_alias_hw_flags_set(struct net *net, const struct fib_rt_info *fri);
  458. void fib_trie_init(void);
  459. struct fib_table *fib_trie_table(u32 id, struct fib_table *alias);
  460. bool fib_lookup_good_nhc(const struct fib_nh_common *nhc, int fib_flags,
  461. const struct flowi4 *flp);
  462. static inline void fib_combine_itag(u32 *itag, const struct fib_result *res)
  463. {
  464. #ifdef CONFIG_IP_ROUTE_CLASSID
  465. struct fib_nh_common *nhc = res->nhc;
  466. #ifdef CONFIG_IP_MULTIPLE_TABLES
  467. u32 rtag;
  468. #endif
  469. if (nhc->nhc_family == AF_INET) {
  470. struct fib_nh *nh;
  471. nh = container_of(nhc, struct fib_nh, nh_common);
  472. *itag = nh->nh_tclassid << 16;
  473. } else {
  474. *itag = 0;
  475. }
  476. #ifdef CONFIG_IP_MULTIPLE_TABLES
  477. rtag = res->tclassid;
  478. if (*itag == 0)
  479. *itag = (rtag<<16);
  480. *itag |= (rtag>>16);
  481. #endif
  482. #endif
  483. }
  484. void fib_flush(struct net *net);
  485. void free_fib_info(struct fib_info *fi);
  486. static inline void fib_info_hold(struct fib_info *fi)
  487. {
  488. refcount_inc(&fi->fib_clntref);
  489. }
  490. static inline void fib_info_put(struct fib_info *fi)
  491. {
  492. if (refcount_dec_and_test(&fi->fib_clntref))
  493. free_fib_info(fi);
  494. }
  495. #ifdef CONFIG_PROC_FS
  496. int __net_init fib_proc_init(struct net *net);
  497. void __net_exit fib_proc_exit(struct net *net);
  498. #else
  499. static inline int fib_proc_init(struct net *net)
  500. {
  501. return 0;
  502. }
  503. static inline void fib_proc_exit(struct net *net)
  504. {
  505. }
  506. #endif
  507. u32 ip_mtu_from_fib_result(struct fib_result *res, __be32 daddr);
  508. int ip_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh,
  509. struct fib_dump_filter *filter,
  510. struct netlink_callback *cb);
  511. int fib_nexthop_info(struct sk_buff *skb, const struct fib_nh_common *nh,
  512. u8 rt_family, unsigned char *flags, bool skip_oif);
  513. int fib_add_nexthop(struct sk_buff *skb, const struct fib_nh_common *nh,
  514. int nh_weight, u8 rt_family, u32 nh_tclassid);
  515. #endif /* _NET_FIB_H */