diff options
author | Patrick McHardy <kaber@trash.net> | 2013-04-17 02:18:26 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-04-17 14:18:33 -0400 |
commit | 8aeb89f214cdb4c3d9e43213d52d4c5b0fb93bbb (patch) | |
tree | ba2175f89efa688ad4e58e0d21842dce4f4c34da /net/tipc | |
parent | ccc4ba2ea23e4507c174620405c5de7bee328f99 (diff) |
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: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/bcast.c | 4 | ||||
-rw-r--r-- | net/tipc/bearer.c | 5 | ||||
-rw-r--r-- | net/tipc/bearer.h | 5 | ||||
-rw-r--r-- | net/tipc/discover.c | 2 | ||||
-rw-r--r-- | net/tipc/eth_media.c | 18 |
5 files changed, 18 insertions, 16 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 2655c9f4ecad..25e159c2feb4 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
@@ -620,10 +620,10 @@ static int tipc_bcbearer_send(struct sk_buff *buf, | |||
620 | continue; /* bearer pair doesn't add anything */ | 620 | continue; /* bearer pair doesn't add anything */ |
621 | 621 | ||
622 | if (!tipc_bearer_blocked(p)) | 622 | if (!tipc_bearer_blocked(p)) |
623 | tipc_bearer_send(p, buf, &p->media->bcast_addr); | 623 | tipc_bearer_send(p, buf, &p->bcast_addr); |
624 | else if (s && !tipc_bearer_blocked(s)) | 624 | else if (s && !tipc_bearer_blocked(s)) |
625 | /* unable to send on primary bearer */ | 625 | /* unable to send on primary bearer */ |
626 | tipc_bearer_send(s, buf, &s->media->bcast_addr); | 626 | tipc_bearer_send(s, buf, &s->bcast_addr); |
627 | else | 627 | else |
628 | /* unable to send on either bearer */ | 628 | /* unable to send on either bearer */ |
629 | continue; | 629 | continue; |
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index aa62f93a9127..45d5398cd957 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -89,9 +89,6 @@ int tipc_register_media(struct tipc_media *m_ptr) | |||
89 | 89 | ||
90 | if ((strlen(m_ptr->name) + 1) > TIPC_MAX_MEDIA_NAME) | 90 | if ((strlen(m_ptr->name) + 1) > TIPC_MAX_MEDIA_NAME) |
91 | goto exit; | 91 | goto exit; |
92 | if ((m_ptr->bcast_addr.media_id != m_ptr->type_id) || | ||
93 | !m_ptr->bcast_addr.broadcast) | ||
94 | goto exit; | ||
95 | if (m_ptr->priority > TIPC_MAX_LINK_PRI) | 92 | if (m_ptr->priority > TIPC_MAX_LINK_PRI) |
96 | goto exit; | 93 | goto exit; |
97 | if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) || | 94 | if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) || |
@@ -407,7 +404,7 @@ restart: | |||
407 | INIT_LIST_HEAD(&b_ptr->links); | 404 | INIT_LIST_HEAD(&b_ptr->links); |
408 | spin_lock_init(&b_ptr->lock); | 405 | spin_lock_init(&b_ptr->lock); |
409 | 406 | ||
410 | res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain); | 407 | res = tipc_disc_create(b_ptr, &b_ptr->bcast_addr, disc_domain); |
411 | if (res) { | 408 | if (res) { |
412 | bearer_disable(b_ptr); | 409 | bearer_disable(b_ptr); |
413 | pr_warn("Bearer <%s> rejected, discovery object creation failed\n", | 410 | pr_warn("Bearer <%s> rejected, discovery object creation failed\n", |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index cc2d74e1f9f7..3b3fa26cb3dd 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
@@ -94,8 +94,8 @@ struct tipc_media { | |||
94 | void (*disable_bearer)(struct tipc_bearer *b_ptr); | 94 | void (*disable_bearer)(struct tipc_bearer *b_ptr); |
95 | int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size); | 95 | int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size); |
96 | int (*addr2msg)(struct tipc_media_addr *a, char *msg_area); | 96 | int (*addr2msg)(struct tipc_media_addr *a, char *msg_area); |
97 | int (*msg2addr)(struct tipc_media_addr *a, char *msg_area); | 97 | int (*msg2addr)(const struct tipc_bearer *b_ptr, |
98 | struct tipc_media_addr bcast_addr; | 98 | struct tipc_media_addr *a, char *msg_area); |
99 | u32 priority; | 99 | u32 priority; |
100 | u32 tolerance; | 100 | u32 tolerance; |
101 | u32 window; | 101 | u32 window; |
@@ -134,6 +134,7 @@ struct tipc_bearer { | |||
134 | char name[TIPC_MAX_BEARER_NAME]; | 134 | char name[TIPC_MAX_BEARER_NAME]; |
135 | spinlock_t lock; | 135 | spinlock_t lock; |
136 | struct tipc_media *media; | 136 | struct tipc_media *media; |
137 | struct tipc_media_addr bcast_addr; | ||
137 | u32 priority; | 138 | u32 priority; |
138 | u32 window; | 139 | u32 window; |
139 | u32 tolerance; | 140 | u32 tolerance; |
diff --git a/net/tipc/discover.c b/net/tipc/discover.c index 1074b9587e81..eedff58d0387 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c | |||
@@ -129,7 +129,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) | |||
129 | int link_fully_up; | 129 | int link_fully_up; |
130 | 130 | ||
131 | media_addr.broadcast = 1; | 131 | media_addr.broadcast = 1; |
132 | b_ptr->media->msg2addr(&media_addr, msg_media_addr(msg)); | 132 | b_ptr->media->msg2addr(b_ptr, &media_addr, msg_media_addr(msg)); |
133 | kfree_skb(buf); | 133 | kfree_skb(buf); |
134 | 134 | ||
135 | /* Ensure message from node is valid and communication is permitted */ | 135 | /* Ensure message from node is valid and communication is permitted */ |
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index 1bdc6df0a79e..06488195f998 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
@@ -77,12 +77,13 @@ static struct notifier_block notifier = { | |||
77 | * Media-dependent "value" field stores MAC address in first 6 bytes | 77 | * Media-dependent "value" field stores MAC address in first 6 bytes |
78 | * and zeroes out the remaining bytes. | 78 | * and zeroes out the remaining bytes. |
79 | */ | 79 | */ |
80 | static void eth_media_addr_set(struct tipc_media_addr *a, char *mac) | 80 | static void eth_media_addr_set(const struct tipc_bearer *tb_ptr, |
81 | struct tipc_media_addr *a, char *mac) | ||
81 | { | 82 | { |
82 | memcpy(a->value, mac, ETH_ALEN); | 83 | memcpy(a->value, mac, ETH_ALEN); |
83 | memset(a->value + ETH_ALEN, 0, sizeof(a->value) - ETH_ALEN); | 84 | memset(a->value + ETH_ALEN, 0, sizeof(a->value) - ETH_ALEN); |
84 | a->media_id = TIPC_MEDIA_TYPE_ETH; | 85 | a->media_id = TIPC_MEDIA_TYPE_ETH; |
85 | a->broadcast = !memcmp(mac, eth_media_info.bcast_addr.value, ETH_ALEN); | 86 | a->broadcast = !memcmp(mac, tb_ptr->bcast_addr.value, ETH_ALEN); |
86 | } | 87 | } |
87 | 88 | ||
88 | /** | 89 | /** |
@@ -201,9 +202,13 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
201 | /* Associate TIPC bearer with Ethernet bearer */ | 202 | /* Associate TIPC bearer with Ethernet bearer */ |
202 | eb_ptr->bearer = tb_ptr; | 203 | eb_ptr->bearer = tb_ptr; |
203 | tb_ptr->usr_handle = (void *)eb_ptr; | 204 | tb_ptr->usr_handle = (void *)eb_ptr; |
205 | memset(tb_ptr->bcast_addr.value, 0, sizeof(tb_ptr->bcast_addr.value)); | ||
206 | memcpy(tb_ptr->bcast_addr.value, dev->broadcast, ETH_ALEN); | ||
207 | tb_ptr->bcast_addr.media_id = TIPC_MEDIA_TYPE_ETH; | ||
208 | tb_ptr->bcast_addr.broadcast = 1; | ||
204 | tb_ptr->mtu = dev->mtu; | 209 | tb_ptr->mtu = dev->mtu; |
205 | tb_ptr->blocked = 0; | 210 | tb_ptr->blocked = 0; |
206 | eth_media_addr_set(&tb_ptr->addr, (char *)dev->dev_addr); | 211 | eth_media_addr_set(tb_ptr, &tb_ptr->addr, (char *)dev->dev_addr); |
207 | return 0; | 212 | return 0; |
208 | } | 213 | } |
209 | 214 | ||
@@ -315,12 +320,13 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area) | |||
315 | /** | 320 | /** |
316 | * eth_str2addr - convert message header address format to Ethernet format | 321 | * eth_str2addr - convert message header address format to Ethernet format |
317 | */ | 322 | */ |
318 | static int eth_msg2addr(struct tipc_media_addr *a, char *msg_area) | 323 | static int eth_msg2addr(const struct tipc_bearer *tb_ptr, |
324 | struct tipc_media_addr *a, char *msg_area) | ||
319 | { | 325 | { |
320 | if (msg_area[TIPC_MEDIA_TYPE_OFFSET] != TIPC_MEDIA_TYPE_ETH) | 326 | if (msg_area[TIPC_MEDIA_TYPE_OFFSET] != TIPC_MEDIA_TYPE_ETH) |
321 | return 1; | 327 | return 1; |
322 | 328 | ||
323 | eth_media_addr_set(a, msg_area + ETH_ADDR_OFFSET); | 329 | eth_media_addr_set(tb_ptr, a, msg_area + ETH_ADDR_OFFSET); |
324 | return 0; | 330 | return 0; |
325 | } | 331 | } |
326 | 332 | ||
@@ -334,8 +340,6 @@ static struct tipc_media eth_media_info = { | |||
334 | .addr2str = eth_addr2str, | 340 | .addr2str = eth_addr2str, |
335 | .addr2msg = eth_addr2msg, | 341 | .addr2msg = eth_addr2msg, |
336 | .msg2addr = eth_msg2addr, | 342 | .msg2addr = eth_msg2addr, |
337 | .bcast_addr = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, | ||
338 | TIPC_MEDIA_TYPE_ETH, 1 }, | ||
339 | .priority = TIPC_DEF_LINK_PRI, | 343 | .priority = TIPC_DEF_LINK_PRI, |
340 | .tolerance = TIPC_DEF_LINK_TOL, | 344 | .tolerance = TIPC_DEF_LINK_TOL, |
341 | .window = TIPC_DEF_LINK_WIN, | 345 | .window = TIPC_DEF_LINK_WIN, |