Skip to content

Commit

Permalink
tipc: add ip/udp media type
Browse files Browse the repository at this point in the history
The ip/udp bearer can be configured in a point-to-point
mode by specifying both local and remote ip/hostname,
or it can be enabled in multicast mode, where links are
established to all tipc nodes that have joined the same
multicast group. The multicast IP address is generated
based on the TIPC network ID, but can be overridden by
using another multicast address as remote ip.

Signed-off-by: Erik Hugne <[email protected]>
Reviewed-by: Jon Maloy <[email protected]>
Reviewed-by: Ying Xue <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Erik Hugne authored and davem330 committed Mar 6, 2015
1 parent 948fa2d commit d0f9193
Show file tree
Hide file tree
Showing 7 changed files with 479 additions and 8 deletions.
9 changes: 9 additions & 0 deletions include/uapi/linux/tipc_netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,20 @@ enum {
TIPC_NLA_BEARER_NAME, /* string */
TIPC_NLA_BEARER_PROP, /* nest */
TIPC_NLA_BEARER_DOMAIN, /* u32 */
TIPC_NLA_BEARER_UDP_OPTS, /* nest */

__TIPC_NLA_BEARER_MAX,
TIPC_NLA_BEARER_MAX = __TIPC_NLA_BEARER_MAX - 1
};

enum {
TIPC_NLA_UDP_UNSPEC,
TIPC_NLA_UDP_LOCAL, /* sockaddr_storage */
TIPC_NLA_UDP_REMOTE, /* sockaddr_storage */

__TIPC_NLA_UDP_MAX,
TIPC_NLA_UDP_MAX = __TIPC_NLA_UDP_MAX - 1
};
/* Socket info */
enum {
TIPC_NLA_SOCK_UNSPEC,
Expand Down
8 changes: 8 additions & 0 deletions net/tipc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ config TIPC_MEDIA_IB
help
Saying Y here will enable support for running TIPC on
IP-over-InfiniBand devices.
config TIPC_MEDIA_UDP
bool "IP/UDP media type support"
depends on TIPC
select NET_UDP_TUNNEL
help
Saying Y here will enable support for running TIPC over IP/UDP
bool
default y
1 change: 1 addition & 0 deletions net/tipc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ tipc-y += addr.o bcast.o bearer.o \
netlink.o netlink_compat.o node.o socket.o eth_media.o \
server.o socket.o

tipc-$(CONFIG_TIPC_MEDIA_UDP) += udp_media.o
tipc-$(CONFIG_TIPC_MEDIA_IB) += ib_media.o
tipc-$(CONFIG_SYSCTL) += sysctl.o
13 changes: 9 additions & 4 deletions net/tipc/bearer.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ static struct tipc_media * const media_info_array[] = {
&eth_media_info,
#ifdef CONFIG_TIPC_MEDIA_IB
&ib_media_info,
#endif
#ifdef CONFIG_TIPC_MEDIA_UDP
&udp_media_info,
#endif
NULL
};
Expand Down Expand Up @@ -216,7 +219,8 @@ void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest)
* tipc_enable_bearer - enable bearer with the given name
*/
static int tipc_enable_bearer(struct net *net, const char *name,
u32 disc_domain, u32 priority)
u32 disc_domain, u32 priority,
struct nlattr *attr[])
{
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct tipc_bearer *b_ptr;
Expand Down Expand Up @@ -304,7 +308,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,

strcpy(b_ptr->name, name);
b_ptr->media = m_ptr;
res = m_ptr->enable_media(net, b_ptr);
res = m_ptr->enable_media(net, b_ptr, attr);
if (res) {
pr_warn("Bearer <%s> rejected, enable failure (%d)\n",
name, -res);
Expand Down Expand Up @@ -372,7 +376,8 @@ static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr,
kfree_rcu(b_ptr, rcu);
}

int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b)
int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,
struct nlattr *attr[])
{
struct net_device *dev;
char *driver_name = strchr((const char *)b->name, ':') + 1;
Expand Down Expand Up @@ -791,7 +796,7 @@ int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info)
}

rtnl_lock();
err = tipc_enable_bearer(net, bearer, domain, prio);
err = tipc_enable_bearer(net, bearer, domain, prio, attrs);
if (err) {
rtnl_unlock();
return err;
Expand Down
12 changes: 9 additions & 3 deletions net/tipc/bearer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <net/genetlink.h>

#define MAX_BEARERS 2
#define MAX_MEDIA 2
#define MAX_MEDIA 3
#define MAX_NODES 4096
#define WSIZE 32

Expand All @@ -59,6 +59,7 @@
*/
#define TIPC_MEDIA_TYPE_ETH 1
#define TIPC_MEDIA_TYPE_IB 2
#define TIPC_MEDIA_TYPE_UDP 3

/**
* struct tipc_node_map - set of node identifiers
Expand Down Expand Up @@ -104,7 +105,8 @@ struct tipc_media {
int (*send_msg)(struct net *net, struct sk_buff *buf,
struct tipc_bearer *b_ptr,
struct tipc_media_addr *dest);
int (*enable_media)(struct net *net, struct tipc_bearer *b_ptr);
int (*enable_media)(struct net *net, struct tipc_bearer *b_ptr,
struct nlattr *attr[]);
void (*disable_media)(struct tipc_bearer *b_ptr);
int (*addr2str)(struct tipc_media_addr *addr,
char *strbuf,
Expand Down Expand Up @@ -183,6 +185,9 @@ extern struct tipc_media eth_media_info;
#ifdef CONFIG_TIPC_MEDIA_IB
extern struct tipc_media ib_media_info;
#endif
#ifdef CONFIG_TIPC_MEDIA_UDP
extern struct tipc_media udp_media_info;
#endif

int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info);
int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info);
Expand All @@ -197,7 +202,8 @@ int tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info);
int tipc_media_set_priority(const char *name, u32 new_value);
int tipc_media_set_window(const char *name, u32 new_value);
void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a);
int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b);
int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,
struct nlattr *attrs[]);
void tipc_disable_l2_media(struct tipc_bearer *b);
int tipc_l2_send_msg(struct net *net, struct sk_buff *buf,
struct tipc_bearer *b, struct tipc_media_addr *dest);
Expand Down
2 changes: 1 addition & 1 deletion net/tipc/msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct plist;
* Note: Headroom should be a multiple of 4 to ensure the TIPC header fields
* are word aligned for quicker access
*/
#define BUF_HEADROOM LL_MAX_HEADER
#define BUF_HEADROOM (LL_MAX_HEADER + 48)

struct tipc_skb_cb {
void *handle;
Expand Down
Loading

0 comments on commit d0f9193

Please sign in to comment.