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

TOMOYO Linux Cross Reference
Linux/include/net/ip_fib.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php