Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75c4a57c authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'ipmr-nl'



Nikolay Aleksandrov says:

====================
net: ipmr: more cleanups and mfc netlink support

This set continues with the minor cleanups in the first 6 patches and
patch 7 adds the first new feature - MFC manipulation via netlink. It
registers NEWROUTE/DELROUTE for that purpose and uses the same semantics
as the already present netlink dump. The only new attribute that is used
is RTA_PREFSRC to denote an MFC_PROXY entry. Currently the table must
exist before adding an entry, and new tables can be created only via
setsockopt, but that will be changed in the future.
This set was tested with modified iproute2 which supports NEWROUTE/DELROUTE
for RTNL_FAMILY_IPMR.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 43cd6991 ccbb0aa6
Loading
Loading
Loading
Loading
+46 −30
Original line number Original line Diff line number Diff line
@@ -9,38 +9,28 @@
#ifdef CONFIG_IP_MROUTE
#ifdef CONFIG_IP_MROUTE
static inline int ip_mroute_opt(int opt)
static inline int ip_mroute_opt(int opt)
{
{
	return (opt >= MRT_BASE) && (opt <= MRT_MAX);
	return opt >= MRT_BASE && opt <= MRT_MAX;
}
}
#else
static inline int ip_mroute_opt(int opt)
{
	return 0;
}
#endif


#ifdef CONFIG_IP_MROUTE
int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
extern int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
extern int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
int ip_mr_init(void);
extern int ip_mr_init(void);
#else
#else
static inline
static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
int ip_mroute_setsockopt(struct sock *sock,
				       char __user *optval, unsigned int optlen)
			 int optname, char __user *optval, unsigned int optlen)
{
{
	return -ENOPROTOOPT;
	return -ENOPROTOOPT;
}
}


static inline
static inline int ip_mroute_getsockopt(struct sock *sock, int optname,
int ip_mroute_getsockopt(struct sock *sock,
				       char __user *optval, int __user *optlen)
			 int optname, char __user *optval, int __user *optlen)
{
{
	return -ENOPROTOOPT;
	return -ENOPROTOOPT;
}
}


static inline
static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
{
{
	return -ENOIOCTLCMD;
	return -ENOIOCTLCMD;
}
}
@@ -49,6 +39,11 @@ static inline int ip_mr_init(void)
{
{
	return 0;
	return 0;
}
}

static inline int ip_mroute_opt(int opt)
{
	return 0;
}
#endif
#endif


struct vif_device {
struct vif_device {
@@ -64,6 +59,32 @@ struct vif_device {


#define VIFF_STATIC 0x8000
#define VIFF_STATIC 0x8000


#define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL)
#define MFC_LINES 64

struct mr_table {
	struct list_head	list;
	possible_net_t		net;
	u32			id;
	struct sock __rcu	*mroute_sk;
	struct timer_list	ipmr_expire_timer;
	struct list_head	mfc_unres_queue;
	struct list_head	mfc_cache_array[MFC_LINES];
	struct vif_device	vif_table[MAXVIFS];
	int			maxvif;
	atomic_t		cache_resolve_queue_len;
	bool			mroute_do_assert;
	bool			mroute_do_pim;
	int			mroute_reg_vif_num;
};

/* mfc_flags:
 * MFC_STATIC - the entry was added statically (not by a routing daemon)
 */
enum {
	MFC_STATIC = BIT(0),
};

struct mfc_cache {
struct mfc_cache {
	struct list_head list;
	struct list_head list;
	__be32 mfc_mcastgrp;			/* Group the entry belongs to 	*/
	__be32 mfc_mcastgrp;			/* Group the entry belongs to 	*/
@@ -89,11 +110,6 @@ struct mfc_cache {
	struct rcu_head	rcu;
	struct rcu_head	rcu;
};
};


#define MFC_STATIC		1
#define MFC_NOTIFY		2

#define MFC_LINES		64

#ifdef __BIG_ENDIAN
#ifdef __BIG_ENDIAN
#define MFC_HASH(a,b)	(((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
#define MFC_HASH(a,b)	(((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
#else
#else
@@ -101,7 +117,7 @@ struct mfc_cache {
#endif
#endif


struct rtmsg;
struct rtmsg;
extern int ipmr_get_route(struct net *net, struct sk_buff *skb,
int ipmr_get_route(struct net *net, struct sk_buff *skb,
		   __be32 saddr, __be32 daddr,
		   __be32 saddr, __be32 daddr,
		   struct rtmsg *rtm, int nowait);
		   struct rtmsg *rtm, int nowait);
#endif
#endif
+5 −0
Original line number Original line Diff line number Diff line
@@ -13,6 +13,11 @@


#define PIM_NULL_REGISTER	cpu_to_be32(0x40000000)
#define PIM_NULL_REGISTER	cpu_to_be32(0x40000000)


static inline bool ipmr_pimsm_enabled(void)
{
	return IS_BUILTIN(CONFIG_IP_PIMSM_V1) || IS_BUILTIN(CONFIG_IP_PIMSM_V2);
}

/* PIMv2 register message header layout (ietf-draft-idmr-pimvsm-v2-00.ps */
/* PIMv2 register message header layout (ietf-draft-idmr-pimvsm-v2-00.ps */
struct pimreghdr
struct pimreghdr
{
{
+0 −1
Original line number Original line Diff line number Diff line
@@ -24,7 +24,6 @@
#include <linux/tcp.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/udp.h>
#include <linux/if_arp.h>
#include <linux/if_arp.h>
#include <linux/mroute.h>
#include <linux/if_vlan.h>
#include <linux/if_vlan.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/in6.h>
#include <linux/in6.h>
+0 −1
Original line number Original line Diff line number Diff line
@@ -76,7 +76,6 @@
#include <linux/igmp.h>
#include <linux/igmp.h>
#include <linux/netfilter_ipv4.h>
#include <linux/netfilter_ipv4.h>
#include <linux/netfilter_bridge.h>
#include <linux/netfilter_bridge.h>
#include <linux/mroute.h>
#include <linux/netlink.h>
#include <linux/netlink.h>
#include <linux/tcp.h>
#include <linux/tcp.h>


+0 −1
Original line number Original line Diff line number Diff line
@@ -30,7 +30,6 @@
#include <linux/tcp.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/udp.h>
#include <linux/if_arp.h>
#include <linux/if_arp.h>
#include <linux/mroute.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/in6.h>
#include <linux/in6.h>
#include <linux/inetdevice.h>
#include <linux/inetdevice.h>
Loading