1 #ifndef __LINUX_MROUTE_H 2 #define __LINUX_MROUTE_H 3 4 #include <linux/in.h> 5 #include <linux/pim.h> 6 #include <linux/rhashtable.h> 7 #include <net/sock.h> 8 #include <uapi/linux/mroute.h> 9 10 #ifdef CONFIG_IP_MROUTE 11 static inline int ip_mroute_opt(int opt) 12 { 13 return opt >= MRT_BASE && opt <= MRT_MAX; 14 } 15 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); 21 #else 22 static inline int ip_mroute_setsockopt(struct sock *sock, int optname, 23 char __user *optval, unsigned int optlen) 24 { 25 return -ENOPROTOOPT; 26 } 27 28 static inline int ip_mroute_getsockopt(struct sock *sock, int optname, 29 char __user *optval, int __user *optlen) 30 { 31 return -ENOPROTOOPT; 32 } 33 34 static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg) 35 { 36 return -ENOIOCTLCMD; 37 } 38 39 static inline int ip_mr_init(void) 40 { 41 return 0; 42 } 43 44 static inline int ip_mroute_opt(int opt) 45 { 46 return 0; 47 } 48 #endif 49 50 struct vif_device { 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 */ 57 __be32 local,remote; /* Addresses(remote for tunnels)*/ 58 int link; /* Physical interface index */ 59 }; 60 61 #define VIFF_STATIC 0x8000 62 63 #define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL) 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; 72 struct vif_device vif_table[MAXVIFS]; 73 struct rhltable mfc_hash; 74 struct list_head mfc_cache_list; 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 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 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 */ 115 struct mfc_cache { 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; 126 127 union { 128 struct { 129 unsigned long expires; 130 struct sk_buff_head unresolved; 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; 139 unsigned long lastuse; 140 unsigned char ttls[MAXVIFS]; 141 } res; 142 } mfc_un; 143 struct list_head list; 144 struct rcu_head rcu; 145 }; 146 147 struct rtmsg; 148 int ipmr_get_route(struct net *net, struct sk_buff *skb, 149 __be32 saddr, __be32 daddr, 150 struct rtmsg *rtm, u32 portid); 151 #endif 152