]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/mroute.h
8021q: fix a potential memory leak
[mirror_ubuntu-bionic-kernel.git] / include / linux / mroute.h
1 #ifndef __LINUX_MROUTE_H
2 #define __LINUX_MROUTE_H
3
4 #include <linux/in.h>
5 #include <linux/pim.h>
6 #include <net/sock.h>
7 #include <uapi/linux/mroute.h>
8
9 #ifdef CONFIG_IP_MROUTE
10 static inline int ip_mroute_opt(int opt)
11 {
12 return (opt >= MRT_BASE) && (opt <= MRT_MAX);
13 }
14 #else
15 static inline int ip_mroute_opt(int opt)
16 {
17 return 0;
18 }
19 #endif
20
21 #ifdef CONFIG_IP_MROUTE
22 extern int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
23 extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
24 extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
25 extern int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
26 extern int ip_mr_init(void);
27 #else
28 static inline
29 int ip_mroute_setsockopt(struct sock *sock,
30 int optname, char __user *optval, unsigned int optlen)
31 {
32 return -ENOPROTOOPT;
33 }
34
35 static inline
36 int ip_mroute_getsockopt(struct sock *sock,
37 int optname, char __user *optval, int __user *optlen)
38 {
39 return -ENOPROTOOPT;
40 }
41
42 static inline
43 int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
44 {
45 return -ENOIOCTLCMD;
46 }
47
48 static inline int ip_mr_init(void)
49 {
50 return 0;
51 }
52 #endif
53
54 struct vif_device {
55 struct net_device *dev; /* Device we are using */
56 unsigned long bytes_in,bytes_out;
57 unsigned long pkt_in,pkt_out; /* Statistics */
58 unsigned long rate_limit; /* Traffic shaping (NI) */
59 unsigned char threshold; /* TTL threshold */
60 unsigned short flags; /* Control flags */
61 __be32 local,remote; /* Addresses(remote for tunnels)*/
62 int link; /* Physical interface index */
63 };
64
65 #define VIFF_STATIC 0x8000
66
67 struct mfc_cache {
68 struct list_head list;
69 __be32 mfc_mcastgrp; /* Group the entry belongs to */
70 __be32 mfc_origin; /* Source of packet */
71 vifi_t mfc_parent; /* Source interface */
72 int mfc_flags; /* Flags on line */
73
74 union {
75 struct {
76 unsigned long expires;
77 struct sk_buff_head unresolved; /* Unresolved buffers */
78 } unres;
79 struct {
80 unsigned long last_assert;
81 int minvif;
82 int maxvif;
83 unsigned long bytes;
84 unsigned long pkt;
85 unsigned long wrong_if;
86 unsigned char ttls[MAXVIFS]; /* TTL thresholds */
87 } res;
88 } mfc_un;
89 struct rcu_head rcu;
90 };
91
92 #define MFC_STATIC 1
93 #define MFC_NOTIFY 2
94
95 #define MFC_LINES 64
96
97 #ifdef __BIG_ENDIAN
98 #define MFC_HASH(a,b) (((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
99 #else
100 #define MFC_HASH(a,b) ((((__force u32)(__be32)a)^(((__force u32)(__be32)b)>>2))&(MFC_LINES-1))
101 #endif
102
103 struct rtmsg;
104 extern int ipmr_get_route(struct net *net, struct sk_buff *skb,
105 __be32 saddr, __be32 daddr,
106 struct rtmsg *rtm, int nowait);
107 #endif