Skip to content

Commit d0f9193

Browse files
Erik Hugnedavem330
authored andcommitted
tipc: add ip/udp media type
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]>
1 parent 948fa2d commit d0f9193

File tree

7 files changed

+479
-8
lines changed

7 files changed

+479
-8
lines changed

include/uapi/linux/tipc_netlink.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,20 @@ enum {
8383
TIPC_NLA_BEARER_NAME, /* string */
8484
TIPC_NLA_BEARER_PROP, /* nest */
8585
TIPC_NLA_BEARER_DOMAIN, /* u32 */
86+
TIPC_NLA_BEARER_UDP_OPTS, /* nest */
8687

8788
__TIPC_NLA_BEARER_MAX,
8889
TIPC_NLA_BEARER_MAX = __TIPC_NLA_BEARER_MAX - 1
8990
};
9091

92+
enum {
93+
TIPC_NLA_UDP_UNSPEC,
94+
TIPC_NLA_UDP_LOCAL, /* sockaddr_storage */
95+
TIPC_NLA_UDP_REMOTE, /* sockaddr_storage */
96+
97+
__TIPC_NLA_UDP_MAX,
98+
TIPC_NLA_UDP_MAX = __TIPC_NLA_UDP_MAX - 1
99+
};
91100
/* Socket info */
92101
enum {
93102
TIPC_NLA_SOCK_UNSPEC,

net/tipc/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,11 @@ config TIPC_MEDIA_IB
2626
help
2727
Saying Y here will enable support for running TIPC on
2828
IP-over-InfiniBand devices.
29+
config TIPC_MEDIA_UDP
30+
bool "IP/UDP media type support"
31+
depends on TIPC
32+
select NET_UDP_TUNNEL
33+
help
34+
Saying Y here will enable support for running TIPC over IP/UDP
35+
bool
36+
default y

net/tipc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ tipc-y += addr.o bcast.o bearer.o \
1010
netlink.o netlink_compat.o node.o socket.o eth_media.o \
1111
server.o socket.o
1212

13+
tipc-$(CONFIG_TIPC_MEDIA_UDP) += udp_media.o
1314
tipc-$(CONFIG_TIPC_MEDIA_IB) += ib_media.o
1415
tipc-$(CONFIG_SYSCTL) += sysctl.o

net/tipc/bearer.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ static struct tipc_media * const media_info_array[] = {
4747
&eth_media_info,
4848
#ifdef CONFIG_TIPC_MEDIA_IB
4949
&ib_media_info,
50+
#endif
51+
#ifdef CONFIG_TIPC_MEDIA_UDP
52+
&udp_media_info,
5053
#endif
5154
NULL
5255
};
@@ -216,7 +219,8 @@ void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest)
216219
* tipc_enable_bearer - enable bearer with the given name
217220
*/
218221
static int tipc_enable_bearer(struct net *net, const char *name,
219-
u32 disc_domain, u32 priority)
222+
u32 disc_domain, u32 priority,
223+
struct nlattr *attr[])
220224
{
221225
struct tipc_net *tn = net_generic(net, tipc_net_id);
222226
struct tipc_bearer *b_ptr;
@@ -304,7 +308,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
304308

305309
strcpy(b_ptr->name, name);
306310
b_ptr->media = m_ptr;
307-
res = m_ptr->enable_media(net, b_ptr);
311+
res = m_ptr->enable_media(net, b_ptr, attr);
308312
if (res) {
309313
pr_warn("Bearer <%s> rejected, enable failure (%d)\n",
310314
name, -res);
@@ -372,7 +376,8 @@ static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr,
372376
kfree_rcu(b_ptr, rcu);
373377
}
374378

375-
int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b)
379+
int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,
380+
struct nlattr *attr[])
376381
{
377382
struct net_device *dev;
378383
char *driver_name = strchr((const char *)b->name, ':') + 1;
@@ -791,7 +796,7 @@ int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info)
791796
}
792797

793798
rtnl_lock();
794-
err = tipc_enable_bearer(net, bearer, domain, prio);
799+
err = tipc_enable_bearer(net, bearer, domain, prio, attrs);
795800
if (err) {
796801
rtnl_unlock();
797802
return err;

net/tipc/bearer.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include <net/genetlink.h>
4242

4343
#define MAX_BEARERS 2
44-
#define MAX_MEDIA 2
44+
#define MAX_MEDIA 3
4545
#define MAX_NODES 4096
4646
#define WSIZE 32
4747

@@ -59,6 +59,7 @@
5959
*/
6060
#define TIPC_MEDIA_TYPE_ETH 1
6161
#define TIPC_MEDIA_TYPE_IB 2
62+
#define TIPC_MEDIA_TYPE_UDP 3
6263

6364
/**
6465
* struct tipc_node_map - set of node identifiers
@@ -104,7 +105,8 @@ struct tipc_media {
104105
int (*send_msg)(struct net *net, struct sk_buff *buf,
105106
struct tipc_bearer *b_ptr,
106107
struct tipc_media_addr *dest);
107-
int (*enable_media)(struct net *net, struct tipc_bearer *b_ptr);
108+
int (*enable_media)(struct net *net, struct tipc_bearer *b_ptr,
109+
struct nlattr *attr[]);
108110
void (*disable_media)(struct tipc_bearer *b_ptr);
109111
int (*addr2str)(struct tipc_media_addr *addr,
110112
char *strbuf,
@@ -183,6 +185,9 @@ extern struct tipc_media eth_media_info;
183185
#ifdef CONFIG_TIPC_MEDIA_IB
184186
extern struct tipc_media ib_media_info;
185187
#endif
188+
#ifdef CONFIG_TIPC_MEDIA_UDP
189+
extern struct tipc_media udp_media_info;
190+
#endif
186191

187192
int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info);
188193
int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info);
@@ -197,7 +202,8 @@ int tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info);
197202
int tipc_media_set_priority(const char *name, u32 new_value);
198203
int tipc_media_set_window(const char *name, u32 new_value);
199204
void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a);
200-
int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b);
205+
int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,
206+
struct nlattr *attrs[]);
201207
void tipc_disable_l2_media(struct tipc_bearer *b);
202208
int tipc_l2_send_msg(struct net *net, struct sk_buff *buf,
203209
struct tipc_bearer *b, struct tipc_media_addr *dest);

net/tipc/msg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ struct plist;
8787
* Note: Headroom should be a multiple of 4 to ensure the TIPC header fields
8888
* are word aligned for quicker access
8989
*/
90-
#define BUF_HEADROOM LL_MAX_HEADER
90+
#define BUF_HEADROOM (LL_MAX_HEADER + 48)
9191

9292
struct tipc_skb_cb {
9393
void *handle;

0 commit comments

Comments
 (0)