]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef __LINUX_MROUTE_H |
2 | #define __LINUX_MROUTE_H | |
3 | ||
1da177e4 | 4 | #include <linux/in.h> |
7c19a3d2 | 5 | #include <linux/pim.h> |
8fb472c0 | 6 | #include <linux/rhashtable.h> |
1da177e4 | 7 | #include <net/sock.h> |
607ca46e | 8 | #include <uapi/linux/mroute.h> |
1da177e4 | 9 | |
6a9fb947 PE |
10 | #ifdef CONFIG_IP_MROUTE |
11 | static inline int ip_mroute_opt(int opt) | |
12 | { | |
520191bb | 13 | return opt >= MRT_BASE && opt <= MRT_MAX; |
6a9fb947 | 14 | } |
6a9fb947 | 15 | |
520191bb NA |
16 | int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int); |
17 | int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *); | |
18 | int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); | |
19 | int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); | |
20 | int ip_mr_init(void); | |
e0835f8f | 21 | #else |
520191bb NA |
22 | static inline int ip_mroute_setsockopt(struct sock *sock, int optname, |
23 | char __user *optval, unsigned int optlen) | |
e0835f8f YH |
24 | { |
25 | return -ENOPROTOOPT; | |
26 | } | |
27 | ||
520191bb NA |
28 | static inline int ip_mroute_getsockopt(struct sock *sock, int optname, |
29 | char __user *optval, int __user *optlen) | |
e0835f8f YH |
30 | { |
31 | return -ENOPROTOOPT; | |
32 | } | |
33 | ||
520191bb | 34 | static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg) |
e0835f8f YH |
35 | { |
36 | return -ENOIOCTLCMD; | |
37 | } | |
38 | ||
39 | static inline int ip_mr_init(void) | |
40 | { | |
41 | return 0; | |
42 | } | |
520191bb NA |
43 | |
44 | static inline int ip_mroute_opt(int opt) | |
45 | { | |
46 | return 0; | |
47 | } | |
e0835f8f | 48 | #endif |
1da177e4 | 49 | |
d94d9fee | 50 | struct vif_device { |
1da177e4 LT |
51 | struct net_device *dev; /* Device we are using */ |
52 | unsigned long bytes_in,bytes_out; | |
53 | unsigned long pkt_in,pkt_out; /* Statistics */ | |
54 | unsigned long rate_limit; /* Traffic shaping (NI) */ | |
55 | unsigned char threshold; /* TTL threshold */ | |
56 | unsigned short flags; /* Control flags */ | |
114c7844 | 57 | __be32 local,remote; /* Addresses(remote for tunnels)*/ |
1da177e4 LT |
58 | int link; /* Physical interface index */ |
59 | }; | |
60 | ||
61 | #define VIFF_STATIC 0x8000 | |
62 | ||
5ea1f132 | 63 | #define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL) |
5ea1f132 NA |
64 | |
65 | struct mr_table { | |
66 | struct list_head list; | |
67 | possible_net_t net; | |
68 | u32 id; | |
69 | struct sock __rcu *mroute_sk; | |
70 | struct timer_list ipmr_expire_timer; | |
71 | struct list_head mfc_unres_queue; | |
5ea1f132 | 72 | struct vif_device vif_table[MAXVIFS]; |
8fb472c0 NA |
73 | struct rhltable mfc_hash; |
74 | struct list_head mfc_cache_list; | |
5ea1f132 NA |
75 | int maxvif; |
76 | atomic_t cache_resolve_queue_len; | |
77 | bool mroute_do_assert; | |
78 | bool mroute_do_pim; | |
79 | int mroute_reg_vif_num; | |
80 | }; | |
81 | ||
06bd6c03 NA |
82 | /* mfc_flags: |
83 | * MFC_STATIC - the entry was added statically (not by a routing daemon) | |
84 | */ | |
85 | enum { | |
86 | MFC_STATIC = BIT(0), | |
87 | }; | |
88 | ||
8fb472c0 NA |
89 | struct mfc_cache_cmp_arg { |
90 | __be32 mfc_mcastgrp; | |
91 | __be32 mfc_origin; | |
92 | }; | |
93 | ||
94 | /** | |
95 | * struct mfc_cache - multicast routing entries | |
96 | * @mnode: rhashtable list | |
97 | * @mfc_mcastgrp: destination multicast group address | |
98 | * @mfc_origin: source address | |
99 | * @cmparg: used for rhashtable comparisons | |
100 | * @mfc_parent: source interface (iif) | |
101 | * @mfc_flags: entry flags | |
102 | * @expires: unresolved entry expire time | |
103 | * @unresolved: unresolved cached skbs | |
104 | * @last_assert: time of last assert | |
105 | * @minvif: minimum VIF id | |
106 | * @maxvif: maximum VIF id | |
107 | * @bytes: bytes that have passed for this entry | |
108 | * @pkt: packets that have passed for this entry | |
109 | * @wrong_if: number of wrong source interface hits | |
110 | * @lastuse: time of last use of the group (traffic or update) | |
111 | * @ttls: OIF TTL threshold array | |
112 | * @list: global entry list | |
113 | * @rcu: used for entry destruction | |
114 | */ | |
d94d9fee | 115 | struct mfc_cache { |
8fb472c0 NA |
116 | struct rhlist_head mnode; |
117 | union { | |
118 | struct { | |
119 | __be32 mfc_mcastgrp; | |
120 | __be32 mfc_origin; | |
121 | }; | |
122 | struct mfc_cache_cmp_arg cmparg; | |
123 | }; | |
124 | vifi_t mfc_parent; | |
125 | int mfc_flags; | |
1da177e4 LT |
126 | |
127 | union { | |
128 | struct { | |
129 | unsigned long expires; | |
8fb472c0 | 130 | struct sk_buff_head unresolved; |
1da177e4 LT |
131 | } unres; |
132 | struct { | |
133 | unsigned long last_assert; | |
134 | int minvif; | |
135 | int maxvif; | |
136 | unsigned long bytes; | |
137 | unsigned long pkt; | |
138 | unsigned long wrong_if; | |
43b9e127 | 139 | unsigned long lastuse; |
8fb472c0 | 140 | unsigned char ttls[MAXVIFS]; |
1da177e4 LT |
141 | } res; |
142 | } mfc_un; | |
8fb472c0 | 143 | struct list_head list; |
a8c9486b | 144 | struct rcu_head rcu; |
1da177e4 LT |
145 | }; |
146 | ||
1da177e4 | 147 | struct rtmsg; |
520191bb NA |
148 | int ipmr_get_route(struct net *net, struct sk_buff *skb, |
149 | __be32 saddr, __be32 daddr, | |
9f09eaea | 150 | struct rtmsg *rtm, u32 portid); |
1da177e4 | 151 | #endif |