netfilter: nf_conntrack: fix hash resizing with namespaces
[safe/jmp/linux-2.6] / include / linux / mroute.h
index e05d54a..c5f3d53 100644 (file)
@@ -2,7 +2,10 @@
 #define __LINUX_MROUTE_H
 
 #include <linux/sockios.h>
+#include <linux/types.h>
+#ifdef __KERNEL__
 #include <linux/in.h>
+#endif
 
 /*
  *     Based on the MROUTING 3.5 defines primarily to keep
@@ -56,20 +59,24 @@ struct vifctl {
        unsigned char vifc_flags;       /* VIFF_ flags */
        unsigned char vifc_threshold;   /* ttl limit */
        unsigned int vifc_rate_limit;   /* Rate limiter values (NI) */
-       struct in_addr vifc_lcl_addr;   /* Our address */
+       union {
+               struct in_addr vifc_lcl_addr;     /* Local interface address */
+               int            vifc_lcl_ifindex;  /* Local interface index   */
+       };
        struct in_addr vifc_rmt_addr;   /* IPIP tunnel addr */
 };
 
-#define VIFF_TUNNEL    0x1     /* IPIP tunnel */
-#define VIFF_SRCRT     0x2     /* NI */
-#define VIFF_REGISTER  0x4     /* register vif */
+#define VIFF_TUNNEL            0x1     /* IPIP tunnel */
+#define VIFF_SRCRT             0x2     /* NI */
+#define VIFF_REGISTER          0x4     /* register vif */
+#define VIFF_USE_IFINDEX       0x8     /* use vifc_lcl_ifindex instead of
+                                          vifc_lcl_addr to find an interface */
 
 /*
  *     Cache manipulation structures for mrouted and PIMd
  */
  
-struct mfcctl
-{
+struct mfcctl {
        struct in_addr mfcc_origin;             /* Origin of mcast      */
        struct in_addr mfcc_mcastgrp;           /* Group in question    */
        vifi_t  mfcc_parent;                    /* Where it arrived     */
@@ -84,8 +91,7 @@ struct mfcctl
  *     Group count retrieval for mrouted
  */
  
-struct sioc_sg_req
-{
+struct sioc_sg_req {
        struct in_addr src;
        struct in_addr grp;
        unsigned long pktcnt;
@@ -97,8 +103,7 @@ struct sioc_sg_req
  *     To get vif packet counts
  */
 
-struct sioc_vif_req
-{
+struct sioc_vif_req {
        vifi_t  vifi;           /* Which iface */
        unsigned long icount;   /* In packets */
        unsigned long ocount;   /* Out packets */
@@ -111,8 +116,7 @@ struct sioc_vif_req
  *     data. Magically happens to be like an IP packet as per the original
  */
  
-struct igmpmsg
-{
+struct igmpmsg {
        __u32 unused1,unused2;
        unsigned char im_msgtype;               /* What is this */
        unsigned char im_mbz;                   /* Must be zero */
@@ -126,33 +130,73 @@ struct igmpmsg
  */
 
 #ifdef __KERNEL__
+#include <linux/pim.h>
 #include <net/sock.h>
 
-extern int ip_mroute_setsockopt(struct sock *, int, char __user *, int);
+#ifdef CONFIG_IP_MROUTE
+static inline int ip_mroute_opt(int opt)
+{
+       return (opt >= MRT_BASE) && (opt <= MRT_BASE + 10);
+}
+#else
+static inline int ip_mroute_opt(int opt)
+{
+       return 0;
+}
+#endif
+
+#ifdef CONFIG_IP_MROUTE
+extern int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
 extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
 extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
-extern void ip_mr_init(void);
+extern int ip_mr_init(void);
+#else
+static inline
+int ip_mroute_setsockopt(struct sock *sock,
+                        int optname, char __user *optval, unsigned int optlen)
+{
+       return -ENOPROTOOPT;
+}
+
+static inline
+int ip_mroute_getsockopt(struct sock *sock,
+                        int optname, char __user *optval, int __user *optlen)
+{
+       return -ENOPROTOOPT;
+}
 
+static inline
+int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
+{
+       return -ENOIOCTLCMD;
+}
 
-struct vif_device
+static inline int ip_mr_init(void)
 {
+       return 0;
+}
+#endif
+
+struct vif_device {
        struct net_device       *dev;                   /* Device we are using */
        unsigned long   bytes_in,bytes_out;
        unsigned long   pkt_in,pkt_out;         /* Statistics                   */
        unsigned long   rate_limit;             /* Traffic shaping (NI)         */
        unsigned char   threshold;              /* TTL threshold                */
        unsigned short  flags;                  /* Control flags                */
-       __u32           local,remote;           /* Addresses(remote for tunnels)*/
+       __be32          local,remote;           /* Addresses(remote for tunnels)*/
        int             link;                   /* Physical interface index     */
 };
 
 #define VIFF_STATIC 0x8000
 
-struct mfc_cache 
-{
+struct mfc_cache {
        struct mfc_cache *next;                 /* Next entry on cache line     */
-       __u32 mfc_mcastgrp;                     /* Group the entry belongs to   */
-       __u32 mfc_origin;                       /* Source of packet             */
+#ifdef CONFIG_NET_NS
+       struct net *mfc_net;
+#endif
+       __be32 mfc_mcastgrp;                    /* Group the entry belongs to   */
+       __be32 mfc_origin;                      /* Source of packet             */
        vifi_t mfc_parent;                      /* Source interface             */
        int mfc_flags;                          /* Flags on line                */
 
@@ -173,15 +217,27 @@ struct mfc_cache
        } mfc_un;
 };
 
+static inline
+struct net *mfc_net(const struct mfc_cache *mfc)
+{
+       return read_pnet(&mfc->mfc_net);
+}
+
+static inline
+void mfc_net_set(struct mfc_cache *mfc, struct net *net)
+{
+       write_pnet(&mfc->mfc_net, hold_net(net));
+}
+
 #define MFC_STATIC             1
 #define MFC_NOTIFY             2
 
 #define MFC_LINES              64
 
 #ifdef __BIG_ENDIAN
-#define MFC_HASH(a,b)  ((((a)>>24)^((b)>>26))&(MFC_LINES-1))
+#define MFC_HASH(a,b)  (((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
 #else
-#define MFC_HASH(a,b)  (((a)^((b)>>2))&(MFC_LINES-1))
+#define MFC_HASH(a,b)  ((((__force u32)(__be32)a)^(((__force u32)(__be32)b)>>2))&(MFC_LINES-1))
 #endif         
 
 #endif
@@ -198,29 +254,9 @@ struct mfc_cache
 #define IGMPMSG_WHOLEPKT       3               /* For PIM Register processing */
 
 #ifdef __KERNEL__
-
-#define PIM_V1_VERSION         __constant_htonl(0x10000000)
-#define PIM_V1_REGISTER                1
-
-#define PIM_VERSION            2
-#define PIM_REGISTER           1
-
-#define PIM_NULL_REGISTER      __constant_htonl(0x40000000)
-
-/* PIMv2 register message header layout (ietf-draft-idmr-pimvsm-v2-00.ps */
-
-struct pimreghdr
-{
-       __u8    type;
-       __u8    reserved;
-       __u16   csum;
-       __u32   flags;
-};
-
-extern int pim_rcv_v1(struct sk_buff *);
-
 struct rtmsg;
-extern int ipmr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait);
+extern int ipmr_get_route(struct net *net, struct sk_buff *skb,
+                         struct rtmsg *rtm, int nowait);
 #endif
 
 #endif