Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _NET_DN_FIB_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _NET_DN_FIB_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/netlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/refcount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) extern const struct nla_policy rtm_dn_policy[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) struct dn_fib_res {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 	struct fib_rule *r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 	struct dn_fib_info *fi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 	unsigned char prefixlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	unsigned char nh_sel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	unsigned char type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	unsigned char scope;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) struct dn_fib_nh {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	struct net_device	*nh_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	unsigned int		nh_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	unsigned char		nh_scope;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	int			nh_weight;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	int			nh_power;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	int			nh_oif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	__le16			nh_gw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) struct dn_fib_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct dn_fib_info	*fib_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct dn_fib_info	*fib_prev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	int 			fib_treeref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	refcount_t		fib_clntref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	int			fib_dead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	unsigned int		fib_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	int			fib_protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	__le16			fib_prefsrc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	__u32			fib_priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	__u32			fib_metrics[RTAX_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	int			fib_nhs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	int			fib_power;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	struct dn_fib_nh	fib_nh[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define dn_fib_dev		fib_nh[0].nh_dev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define DN_FIB_RES_RESET(res)	((res).nh_sel = 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define DN_FIB_RES_NH(res)	((res).fi->fib_nh[(res).nh_sel])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define DN_FIB_RES_PREFSRC(res)	((res).fi->fib_prefsrc ? : __dn_fib_res_prefsrc(&res))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define DN_FIB_RES_GW(res)	(DN_FIB_RES_NH(res).nh_gw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define DN_FIB_RES_DEV(res)	(DN_FIB_RES_NH(res).nh_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define DN_FIB_RES_OIF(res)	(DN_FIB_RES_NH(res).nh_oif)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	__le16	datum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) } dn_fib_key_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	__le16	datum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) } dn_fib_hash_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	__u16	datum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) } dn_fib_idx_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) struct dn_fib_node {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct dn_fib_node *fn_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	struct dn_fib_info *fn_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) #define DN_FIB_INFO(f) ((f)->fn_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	dn_fib_key_t	fn_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	u8		fn_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	u8		fn_scope;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	u8		fn_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) struct dn_fib_table {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	struct hlist_node hlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	u32 n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	int (*insert)(struct dn_fib_table *t, struct rtmsg *r, 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			struct nlattr *attrs[], struct nlmsghdr *n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			struct netlink_skb_parms *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	int (*delete)(struct dn_fib_table *t, struct rtmsg *r,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			struct nlattr *attrs[], struct nlmsghdr *n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 			struct netlink_skb_parms *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	int (*lookup)(struct dn_fib_table *t, const struct flowidn *fld,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			struct dn_fib_res *res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	int (*flush)(struct dn_fib_table *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	unsigned char data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) #ifdef CONFIG_DECNET_ROUTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * dn_fib.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) void dn_fib_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) void dn_fib_cleanup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) int dn_fib_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 				       struct nlattr *attrs[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 				       const struct nlmsghdr *nlh, int *errp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int dn_fib_semantic_match(int type, struct dn_fib_info *fi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			  const struct flowidn *fld, struct dn_fib_res *res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) void dn_fib_release_info(struct dn_fib_info *fi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) void dn_fib_flush(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) void dn_fib_select_multipath(const struct flowidn *fld, struct dn_fib_res *res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * dn_tables.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct dn_fib_table *dn_fib_get_table(u32 n, int creat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct dn_fib_table *dn_fib_empty_table(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) void dn_fib_table_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) void dn_fib_table_cleanup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  * dn_rules.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) void dn_fib_rules_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) void dn_fib_rules_cleanup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) unsigned int dnet_addr_type(__le16 addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) int dn_fib_lookup(struct flowidn *fld, struct dn_fib_res *res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) void dn_fib_free_info(struct dn_fib_info *fi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static inline void dn_fib_info_put(struct dn_fib_info *fi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	if (refcount_dec_and_test(&fi->fib_clntref))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		dn_fib_free_info(fi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) static inline void dn_fib_res_put(struct dn_fib_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	if (res->fi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		dn_fib_info_put(res->fi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	if (res->r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		fib_rule_put(res->r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #else /* Endnode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #define dn_fib_init()  do { } while(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) #define dn_fib_cleanup() do { } while(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #define dn_fib_lookup(fl, res) (-ESRCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #define dn_fib_info_put(fi) do { } while(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #define dn_fib_select_multipath(fl, res) do { } while(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #define dn_fib_rules_policy(saddr,res,flags) (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #define dn_fib_res_put(res) do { } while(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #endif /* CONFIG_DECNET_ROUTER */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) static inline __le16 dnet_make_mask(int n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	if (n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		return cpu_to_le16(~((1 << (16 - n)) - 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	return cpu_to_le16(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) #endif /* _NET_DN_FIB_H */