]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/net/dn_fib.h
1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/netlink.h>
6 #include <linux/refcount.h>
8 extern const struct nla_policy rtm_dn_policy
[];
12 struct dn_fib_info
*fi
;
13 unsigned char prefixlen
;
20 struct net_device
*nh_dev
;
21 unsigned int nh_flags
;
22 unsigned char nh_scope
;
30 struct dn_fib_info
*fib_next
;
31 struct dn_fib_info
*fib_prev
;
33 refcount_t fib_clntref
;
35 unsigned int fib_flags
;
39 __u32 fib_metrics
[RTAX_MAX
];
42 struct dn_fib_nh fib_nh
[0];
43 #define dn_fib_dev fib_nh[0].nh_dev
47 #define DN_FIB_RES_RESET(res) ((res).nh_sel = 0)
48 #define DN_FIB_RES_NH(res) ((res).fi->fib_nh[(res).nh_sel])
50 #define DN_FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __dn_fib_res_prefsrc(&res))
51 #define DN_FIB_RES_GW(res) (DN_FIB_RES_NH(res).nh_gw)
52 #define DN_FIB_RES_DEV(res) (DN_FIB_RES_NH(res).nh_dev)
53 #define DN_FIB_RES_OIF(res) (DN_FIB_RES_NH(res).nh_oif)
68 struct dn_fib_node
*fn_next
;
69 struct dn_fib_info
*fn_info
;
70 #define DN_FIB_INFO(f) ((f)->fn_info)
79 struct hlist_node hlist
;
82 int (*insert
)(struct dn_fib_table
*t
, struct rtmsg
*r
,
83 struct nlattr
*attrs
[], struct nlmsghdr
*n
,
84 struct netlink_skb_parms
*req
);
85 int (*delete)(struct dn_fib_table
*t
, struct rtmsg
*r
,
86 struct nlattr
*attrs
[], struct nlmsghdr
*n
,
87 struct netlink_skb_parms
*req
);
88 int (*lookup
)(struct dn_fib_table
*t
, const struct flowidn
*fld
,
89 struct dn_fib_res
*res
);
90 int (*flush
)(struct dn_fib_table
*t
);
91 int (*dump
)(struct dn_fib_table
*t
, struct sk_buff
*skb
, struct netlink_callback
*cb
);
96 #ifdef CONFIG_DECNET_ROUTER
100 void dn_fib_init(void);
101 void dn_fib_cleanup(void);
103 int dn_fib_ioctl(struct socket
*sock
, unsigned int cmd
, unsigned long arg
);
104 struct dn_fib_info
*dn_fib_create_info(const struct rtmsg
*r
,
105 struct nlattr
*attrs
[],
106 const struct nlmsghdr
*nlh
, int *errp
);
107 int dn_fib_semantic_match(int type
, struct dn_fib_info
*fi
,
108 const struct flowidn
*fld
, struct dn_fib_res
*res
);
109 void dn_fib_release_info(struct dn_fib_info
*fi
);
110 void dn_fib_flush(void);
111 void dn_fib_select_multipath(const struct flowidn
*fld
, struct dn_fib_res
*res
);
116 struct dn_fib_table
*dn_fib_get_table(u32 n
, int creat
);
117 struct dn_fib_table
*dn_fib_empty_table(void);
118 void dn_fib_table_init(void);
119 void dn_fib_table_cleanup(void);
124 void dn_fib_rules_init(void);
125 void dn_fib_rules_cleanup(void);
126 unsigned int dnet_addr_type(__le16 addr
);
127 int dn_fib_lookup(struct flowidn
*fld
, struct dn_fib_res
*res
);
129 int dn_fib_dump(struct sk_buff
*skb
, struct netlink_callback
*cb
);
131 void dn_fib_free_info(struct dn_fib_info
*fi
);
133 static inline void dn_fib_info_put(struct dn_fib_info
*fi
)
135 if (refcount_dec_and_test(&fi
->fib_clntref
))
136 dn_fib_free_info(fi
);
139 static inline void dn_fib_res_put(struct dn_fib_res
*res
)
142 dn_fib_info_put(res
->fi
);
144 fib_rule_put(res
->r
);
149 #define dn_fib_init() do { } while(0)
150 #define dn_fib_cleanup() do { } while(0)
152 #define dn_fib_lookup(fl, res) (-ESRCH)
153 #define dn_fib_info_put(fi) do { } while(0)
154 #define dn_fib_select_multipath(fl, res) do { } while(0)
155 #define dn_fib_rules_policy(saddr,res,flags) (0)
156 #define dn_fib_res_put(res) do { } while(0)
158 #endif /* CONFIG_DECNET_ROUTER */
160 static inline __le16
dnet_make_mask(int n
)
163 return cpu_to_le16(~((1 << (16 - n
)) - 1));
164 return cpu_to_le16(0);
167 #endif /* _NET_DN_FIB_H */