Commit 8aeb89f2 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

tipc: move bcast_addr from struct tipc_media to struct tipc_bearer

Some network protocols, like InfiniBand, don't have a fixed broadcast
address but one that depends on the configuration. Move the bcast_addr
to struct tipc_bearer and initialize it with the broadcast address of
the network device when the bearer is enabled.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ccc4ba2e
...@@ -620,10 +620,10 @@ static int tipc_bcbearer_send(struct sk_buff *buf, ...@@ -620,10 +620,10 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
continue; /* bearer pair doesn't add anything */ continue; /* bearer pair doesn't add anything */
if (!tipc_bearer_blocked(p)) if (!tipc_bearer_blocked(p))
tipc_bearer_send(p, buf, &p->media->bcast_addr); tipc_bearer_send(p, buf, &p->bcast_addr);
else if (s && !tipc_bearer_blocked(s)) else if (s && !tipc_bearer_blocked(s))
/* unable to send on primary bearer */ /* unable to send on primary bearer */
tipc_bearer_send(s, buf, &s->media->bcast_addr); tipc_bearer_send(s, buf, &s->bcast_addr);
else else
/* unable to send on either bearer */ /* unable to send on either bearer */
continue; continue;
......
...@@ -89,9 +89,6 @@ int tipc_register_media(struct tipc_media *m_ptr) ...@@ -89,9 +89,6 @@ int tipc_register_media(struct tipc_media *m_ptr)
if ((strlen(m_ptr->name) + 1) > TIPC_MAX_MEDIA_NAME) if ((strlen(m_ptr->name) + 1) > TIPC_MAX_MEDIA_NAME)
goto exit; goto exit;
if ((m_ptr->bcast_addr.media_id != m_ptr->type_id) ||
!m_ptr->bcast_addr.broadcast)
goto exit;
if (m_ptr->priority > TIPC_MAX_LINK_PRI) if (m_ptr->priority > TIPC_MAX_LINK_PRI)
goto exit; goto exit;
if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) || if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) ||
...@@ -407,7 +404,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) ...@@ -407,7 +404,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
INIT_LIST_HEAD(&b_ptr->links); INIT_LIST_HEAD(&b_ptr->links);
spin_lock_init(&b_ptr->lock); spin_lock_init(&b_ptr->lock);
res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain); res = tipc_disc_create(b_ptr, &b_ptr->bcast_addr, disc_domain);
if (res) { if (res) {
bearer_disable(b_ptr); bearer_disable(b_ptr);
pr_warn("Bearer <%s> rejected, discovery object creation failed\n", pr_warn("Bearer <%s> rejected, discovery object creation failed\n",
......
...@@ -94,8 +94,8 @@ struct tipc_media { ...@@ -94,8 +94,8 @@ struct tipc_media {
void (*disable_bearer)(struct tipc_bearer *b_ptr); void (*disable_bearer)(struct tipc_bearer *b_ptr);
int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size); int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size);
int (*addr2msg)(struct tipc_media_addr *a, char *msg_area); int (*addr2msg)(struct tipc_media_addr *a, char *msg_area);
int (*msg2addr)(struct tipc_media_addr *a, char *msg_area); int (*msg2addr)(const struct tipc_bearer *b_ptr,
struct tipc_media_addr bcast_addr; struct tipc_media_addr *a, char *msg_area);
u32 priority; u32 priority;
u32 tolerance; u32 tolerance;
u32 window; u32 window;
...@@ -134,6 +134,7 @@ struct tipc_bearer { ...@@ -134,6 +134,7 @@ struct tipc_bearer {
char name[TIPC_MAX_BEARER_NAME]; char name[TIPC_MAX_BEARER_NAME];
spinlock_t lock; spinlock_t lock;
struct tipc_media *media; struct tipc_media *media;
struct tipc_media_addr bcast_addr;
u32 priority; u32 priority;
u32 window; u32 window;
u32 tolerance; u32 tolerance;
......
...@@ -129,7 +129,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) ...@@ -129,7 +129,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
int link_fully_up; int link_fully_up;
media_addr.broadcast = 1; media_addr.broadcast = 1;
b_ptr->media->msg2addr(&media_addr, msg_media_addr(msg)); b_ptr->media->msg2addr(b_ptr, &media_addr, msg_media_addr(msg));
kfree_skb(buf); kfree_skb(buf);
/* Ensure message from node is valid and communication is permitted */ /* Ensure message from node is valid and communication is permitted */
......
...@@ -77,12 +77,13 @@ static struct notifier_block notifier = { ...@@ -77,12 +77,13 @@ static struct notifier_block notifier = {
* Media-dependent "value" field stores MAC address in first 6 bytes * Media-dependent "value" field stores MAC address in first 6 bytes
* and zeroes out the remaining bytes. * and zeroes out the remaining bytes.
*/ */
static void eth_media_addr_set(struct tipc_media_addr *a, char *mac) static void eth_media_addr_set(const struct tipc_bearer *tb_ptr,
struct tipc_media_addr *a, char *mac)
{ {
memcpy(a->value, mac, ETH_ALEN); memcpy(a->value, mac, ETH_ALEN);
memset(a->value + ETH_ALEN, 0, sizeof(a->value) - ETH_ALEN); memset(a->value + ETH_ALEN, 0, sizeof(a->value) - ETH_ALEN);
a->media_id = TIPC_MEDIA_TYPE_ETH; a->media_id = TIPC_MEDIA_TYPE_ETH;
a->broadcast = !memcmp(mac, eth_media_info.bcast_addr.value, ETH_ALEN); a->broadcast = !memcmp(mac, tb_ptr->bcast_addr.value, ETH_ALEN);
} }
/** /**
...@@ -201,9 +202,13 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) ...@@ -201,9 +202,13 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
/* Associate TIPC bearer with Ethernet bearer */ /* Associate TIPC bearer with Ethernet bearer */
eb_ptr->bearer = tb_ptr; eb_ptr->bearer = tb_ptr;
tb_ptr->usr_handle = (void *)eb_ptr; tb_ptr->usr_handle = (void *)eb_ptr;
memset(tb_ptr->bcast_addr.value, 0, sizeof(tb_ptr->bcast_addr.value));
memcpy(tb_ptr->bcast_addr.value, dev->broadcast, ETH_ALEN);
tb_ptr->bcast_addr.media_id = TIPC_MEDIA_TYPE_ETH;
tb_ptr->bcast_addr.broadcast = 1;
tb_ptr->mtu = dev->mtu; tb_ptr->mtu = dev->mtu;
tb_ptr->blocked = 0; tb_ptr->blocked = 0;
eth_media_addr_set(&tb_ptr->addr, (char *)dev->dev_addr); eth_media_addr_set(tb_ptr, &tb_ptr->addr, (char *)dev->dev_addr);
return 0; return 0;
} }
...@@ -315,12 +320,13 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area) ...@@ -315,12 +320,13 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area)
/** /**
* eth_str2addr - convert message header address format to Ethernet format * eth_str2addr - convert message header address format to Ethernet format
*/ */
static int eth_msg2addr(struct tipc_media_addr *a, char *msg_area) static int eth_msg2addr(const struct tipc_bearer *tb_ptr,
struct tipc_media_addr *a, char *msg_area)
{ {
if (msg_area[TIPC_MEDIA_TYPE_OFFSET] != TIPC_MEDIA_TYPE_ETH) if (msg_area[TIPC_MEDIA_TYPE_OFFSET] != TIPC_MEDIA_TYPE_ETH)
return 1; return 1;
eth_media_addr_set(a, msg_area + ETH_ADDR_OFFSET); eth_media_addr_set(tb_ptr, a, msg_area + ETH_ADDR_OFFSET);
return 0; return 0;
} }
...@@ -334,8 +340,6 @@ static struct tipc_media eth_media_info = { ...@@ -334,8 +340,6 @@ static struct tipc_media eth_media_info = {
.addr2str = eth_addr2str, .addr2str = eth_addr2str,
.addr2msg = eth_addr2msg, .addr2msg = eth_addr2msg,
.msg2addr = eth_msg2addr, .msg2addr = eth_msg2addr,
.bcast_addr = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
TIPC_MEDIA_TYPE_ETH, 1 },
.priority = TIPC_DEF_LINK_PRI, .priority = TIPC_DEF_LINK_PRI,
.tolerance = TIPC_DEF_LINK_TOL, .tolerance = TIPC_DEF_LINK_TOL,
.window = TIPC_DEF_LINK_WIN, .window = TIPC_DEF_LINK_WIN,
......
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