Commit b9022b53 authored by Taehee Yoo's avatar Taehee Yoo Committed by David S. Miller

amt: add control plane of amt interface

It adds definitions and control plane code for AMT.
this is very similar to udp tunneling interfaces such as gtp, vxlan, etc.
In the next patch, data plane code will be added.
Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 741948ff
......@@ -1020,6 +1020,14 @@ S: Maintained
F: Documentation/devicetree/bindings/iio/light/ams,as73211.yaml
F: drivers/iio/light/as73211.c
AMT (Automatic Multicast Tunneling)
M: Taehee Yoo <ap420073@gmail.com>
L: netdev@vger.kernel.org
S: Maintained
T: git git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git
T: git git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git
F: drivers/net/amt.c
ANALOG DEVICES INC AD7192 DRIVER
M: Alexandru Tachici <alexandru.tachici@analog.com>
L: linux-iio@vger.kernel.org
......
......@@ -291,6 +291,22 @@ config GTP
To compile this drivers as a module, choose M here: the module
will be called gtp.
config AMT
tristate "Automatic Multicast Tunneling (AMT)"
depends on INET && IP_MULTICAST
select NET_UDP_TUNNEL
help
This allows one to create AMT(Automatic Multicast Tunneling)
virtual interfaces that provide multicast tunneling.
There are two roles, Gateway, and Relay.
Gateway Encapsulates IGMP/MLD traffic from listeners to the Relay.
Gateway Decapsulates multicast traffic from the Relay to Listeners.
Relay Encapsulates multicast traffic from Sources to Gateway.
Relay Decapsulates IGMP/MLD traffic from Gateway.
To compile this drivers as a module, choose M here: the module
will be called amt.
config MACSEC
tristate "IEEE 802.1AE MAC-level encryption (MACsec)"
select CRYPTO
......
......@@ -14,6 +14,7 @@ obj-$(CONFIG_WIREGUARD) += wireguard/
obj-$(CONFIG_EQUALIZER) += eql.o
obj-$(CONFIG_IFB) += ifb.o
obj-$(CONFIG_MACSEC) += macsec.o
obj-$(CONFIG_AMT) += amt.o
obj-$(CONFIG_MACVLAN) += macvlan.o
obj-$(CONFIG_MACVTAP) += macvtap.o
obj-$(CONFIG_MII) += mii.o
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (c) 2021 Taehee Yoo <ap420073@gmail.com>
*/
#ifndef _NET_AMT_H_
#define _NET_AMT_H_
#include <linux/siphash.h>
#include <linux/jhash.h>
enum amt_msg_type {
AMT_MSG_DISCOVERY = 1,
AMT_MSG_ADVERTISEMENT,
AMT_MSG_REQUEST,
AMT_MSG_MEMBERSHIP_QUERY,
AMT_MSG_MEMBERSHIP_UPDATE,
AMT_MSG_MULTICAST_DATA,
AMT_MSG_TEARDOWM,
__AMT_MSG_MAX,
};
#define AMT_MSG_MAX (__AMT_MSG_MAX - 1)
enum amt_status {
AMT_STATUS_INIT,
AMT_STATUS_SENT_DISCOVERY,
AMT_STATUS_RECEIVED_DISCOVERY,
AMT_STATUS_SENT_ADVERTISEMENT,
AMT_STATUS_RECEIVED_ADVERTISEMENT,
AMT_STATUS_SENT_REQUEST,
AMT_STATUS_RECEIVED_REQUEST,
AMT_STATUS_SENT_QUERY,
AMT_STATUS_RECEIVED_QUERY,
AMT_STATUS_SENT_UPDATE,
AMT_STATUS_RECEIVED_UPDATE,
__AMT_STATUS_MAX,
};
#define AMT_STATUS_MAX (__AMT_STATUS_MAX - 1)
struct amt_header_discovery {
#if defined(__LITTLE_ENDIAN_BITFIELD)
u32 type:4,
version:4,
reserved:24;
#elif defined(__BIG_ENDIAN_BITFIELD)
u32 version:4,
type:4,
reserved:24;
#else
#error "Please fix <asm/byteorder.h>"
#endif
__be32 nonce;
} __packed;
struct amt_header_advertisement {
#if defined(__LITTLE_ENDIAN_BITFIELD)
u32 type:4,
version:4,
reserved:24;
#elif defined(__BIG_ENDIAN_BITFIELD)
u32 version:4,
type:4,
reserved:24;
#else
#error "Please fix <asm/byteorder.h>"
#endif
__be32 nonce;
__be32 ip4;
} __packed;
struct amt_header_request {
#if defined(__LITTLE_ENDIAN_BITFIELD)
u32 type:4,
version:4,
reserved1:7,
p:1,
reserved2:16;
#elif defined(__BIG_ENDIAN_BITFIELD)
u32 version:4,
type:4,
p:1,
reserved1:7,
reserved2:16;
#else
#error "Please fix <asm/byteorder.h>"
#endif
__be32 nonce;
} __packed;
struct amt_header_membership_query {
#if defined(__LITTLE_ENDIAN_BITFIELD)
u64 type:4,
version:4,
reserved:6,
l:1,
g:1,
response_mac:48;
#elif defined(__BIG_ENDIAN_BITFIELD)
u64 version:4,
type:4,
g:1,
l:1,
reserved:6,
response_mac:48;
#else
#error "Please fix <asm/byteorder.h>"
#endif
__be32 nonce;
} __packed;
struct amt_header_membership_update {
#if defined(__LITTLE_ENDIAN_BITFIELD)
u64 type:4,
version:4,
reserved:8,
response_mac:48;
#elif defined(__BIG_ENDIAN_BITFIELD)
u64 version:4,
type:4,
reserved:8,
response_mac:48;
#else
#error "Please fix <asm/byteorder.h>"
#endif
__be32 nonce;
} __packed;
struct amt_header_mcast_data {
#if defined(__LITTLE_ENDIAN_BITFIELD)
u16 type:4,
version:4,
reserved:8;
#elif defined(__BIG_ENDIAN_BITFIELD)
u16 version:4,
type:4,
reserved:8;
#else
#error "Please fix <asm/byteorder.h>"
#endif
} __packed;
struct amt_gw_headers {
union {
struct amt_header_discovery discovery;
struct amt_header_request request;
struct amt_header_membership_update update;
};
} __packed;
struct amt_relay_headers {
union {
struct amt_header_advertisement advertisement;
struct amt_header_membership_query query;
struct amt_header_mcast_data data;
};
} __packed;
struct amt_dev {
struct net_device *dev;
struct net_device *stream_dev;
struct net *net;
/* Global lock for amt device */
spinlock_t lock;
/* Used only in relay mode */
struct list_head tunnel_list;
struct gro_cells gro_cells;
/* Protected by RTNL */
struct delayed_work discovery_wq;
/* Protected by RTNL */
struct delayed_work req_wq;
/* Protected by RTNL */
struct delayed_work secret_wq;
/* AMT status */
enum amt_status status;
/* Generated key */
siphash_key_t key;
struct socket __rcu *sock;
u32 max_groups;
u32 max_sources;
u32 hash_buckets;
u32 hash_seed;
/* Default 128 */
u32 max_tunnels;
/* Default 128 */
u32 nr_tunnels;
/* Gateway or Relay mode */
u32 mode;
/* Default 2268 */
__be16 relay_port;
/* Default 2268 */
__be16 gw_port;
/* Outer local ip */
__be32 local_ip;
/* Outer remote ip */
__be32 remote_ip;
/* Outer discovery ip */
__be32 discovery_ip;
/* Only used in gateway mode */
__be32 nonce;
/* Gateway sent request and received query */
bool ready4;
bool ready6;
u8 req_cnt;
u8 qi;
u64 qrv;
u64 qri;
/* Used only in gateway mode */
u64 mac:48,
reserved:16;
};
#define AMT_MAX_GROUP 32
#define AMT_MAX_SOURCE 128
#define AMT_HSIZE_SHIFT 8
#define AMT_HSIZE (1 << AMT_HSIZE_SHIFT)
#define AMT_INIT_QUERY_INTERVAL 125
#define IANA_AMT_UDP_PORT 2268
#define AMT_MAX_TUNNELS 128
#define AMT_MAX_REQS 128
#define AMT_GW_HLEN (sizeof(struct iphdr) + \
sizeof(struct udphdr) + \
sizeof(struct amt_gw_headers))
#define AMT_RELAY_HLEN (sizeof(struct iphdr) + \
sizeof(struct udphdr) + \
sizeof(struct amt_relay_headers))
static inline bool netif_is_amt(const struct net_device *dev)
{
return dev->rtnl_link_ops && !strcmp(dev->rtnl_link_ops->kind, "amt");
}
#endif /* _NET_AMT_H_ */
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2021 Taehee Yoo <ap420073@gmail.com>
*/
#ifndef _UAPI_AMT_H_
#define _UAPI_AMT_H_
enum ifla_amt_mode {
/* AMT interface works as Gateway mode.
* The Gateway mode encapsulates IGMP/MLD traffic and decapsulates
* multicast traffic.
*/
AMT_MODE_GATEWAY = 0,
/* AMT interface works as Relay mode.
* The Relay mode encapsulates multicast traffic and decapsulates
* IGMP/MLD traffic.
*/
AMT_MODE_RELAY,
__AMT_MODE_MAX,
};
#define AMT_MODE_MAX (__AMT_MODE_MAX - 1)
enum {
IFLA_AMT_UNSPEC,
/* This attribute specify mode etier Gateway or Relay. */
IFLA_AMT_MODE,
/* This attribute specify Relay port.
* AMT interface is created as Gateway mode, this attribute is used
* to specify relay(remote) port.
* AMT interface is created as Relay mode, this attribute is used
* as local port.
*/
IFLA_AMT_RELAY_PORT,
/* This attribute specify Gateway port.
* AMT interface is created as Gateway mode, this attribute is used
* as local port.
* AMT interface is created as Relay mode, this attribute is not used.
*/
IFLA_AMT_GATEWAY_PORT,
/* This attribute specify physical device */
IFLA_AMT_LINK,
/* This attribute specify local ip address */
IFLA_AMT_LOCAL_IP,
/* This attribute specify Relay ip address.
* So, this is not used by Relay.
*/
IFLA_AMT_REMOTE_IP,
/* This attribute specify Discovery ip address.
* When Gateway get started, it send discovery message to find the
* Relay's ip address.
* So, this is not used by Relay.
*/
IFLA_AMT_DISCOVERY_IP,
/* This attribute specify number of maximum tunnel. */
IFLA_AMT_MAX_TUNNELS,
__IFLA_AMT_MAX,
};
#define IFLA_AMT_MAX (__IFLA_AMT_MAX - 1)
#endif /* _UAPI_AMT_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment