diff options
-rw-r--r-- | net/tipc/bearer.c | 14 | ||||
-rw-r--r-- | net/tipc/bearer.h | 17 | ||||
-rw-r--r-- | net/tipc/discover.c | 4 | ||||
-rw-r--r-- | net/tipc/eth_media.c | 22 | ||||
-rw-r--r-- | net/tipc/msg.c | 9 | ||||
-rw-r--r-- | net/tipc/msg.h | 16 |
6 files changed, 41 insertions, 41 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 17652f20a359..aa37261626d6 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -108,7 +108,8 @@ int tipc_register_media(struct media *m_ptr) | |||
108 | 108 | ||
109 | if (!media_name_valid(m_ptr->name)) | 109 | if (!media_name_valid(m_ptr->name)) |
110 | goto exit; | 110 | goto exit; |
111 | if (m_ptr->bcast_addr.type != htonl(m_ptr->type_id)) | 111 | if ((m_ptr->bcast_addr.media_id != m_ptr->type_id) || |
112 | !m_ptr->bcast_addr.broadcast) | ||
112 | goto exit; | 113 | goto exit; |
113 | if (m_ptr->priority > TIPC_MAX_LINK_PRI) | 114 | if (m_ptr->priority > TIPC_MAX_LINK_PRI) |
114 | goto exit; | 115 | goto exit; |
@@ -138,20 +139,17 @@ void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a) | |||
138 | { | 139 | { |
139 | char addr_str[MAX_ADDR_STR]; | 140 | char addr_str[MAX_ADDR_STR]; |
140 | struct media *m_ptr; | 141 | struct media *m_ptr; |
141 | u32 media_type; | ||
142 | 142 | ||
143 | media_type = ntohl(a->type); | 143 | m_ptr = media_find_id(a->media_id); |
144 | m_ptr = media_find_id(media_type); | ||
145 | 144 | ||
146 | if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str))) | 145 | if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str))) |
147 | tipc_printf(pb, "%s(%s)", m_ptr->name, addr_str); | 146 | tipc_printf(pb, "%s(%s)", m_ptr->name, addr_str); |
148 | else { | 147 | else { |
149 | unchar *addr = (unchar *)&a->dev_addr; | ||
150 | u32 i; | 148 | u32 i; |
151 | 149 | ||
152 | tipc_printf(pb, "UNKNOWN(%u)", media_type); | 150 | tipc_printf(pb, "UNKNOWN(%u)", a->media_id); |
153 | for (i = 0; i < (sizeof(*a) - sizeof(a->type)); i++) | 151 | for (i = 0; i < sizeof(a->value); i++) |
154 | tipc_printf(pb, "-%02x", addr[i]); | 152 | tipc_printf(pb, "-%02x", a->value[i]); |
155 | } | 153 | } |
156 | } | 154 | } |
157 | 155 | ||
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index 41a61d219c38..54a5a575d69a 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
@@ -59,17 +59,16 @@ | |||
59 | #define TIPC_MEDIA_TYPE_ETH 1 | 59 | #define TIPC_MEDIA_TYPE_ETH 1 |
60 | 60 | ||
61 | /* | 61 | /* |
62 | * Destination address structure used by TIPC bearers when sending messages | 62 | * struct tipc_media_addr - destination address used by TIPC bearers |
63 | * | 63 | * @value: address info (format defined by media) |
64 | * IMPORTANT: The fields of this structure MUST be stored using the specified | 64 | * @media_id: TIPC media type identifier |
65 | * byte order indicated below, as the structure is exchanged between nodes | 65 | * @broadcast: non-zero if address is a broadcast address |
66 | * as part of a link setup process. | ||
67 | */ | 66 | */ |
67 | |||
68 | struct tipc_media_addr { | 68 | struct tipc_media_addr { |
69 | __be32 type; /* bearer type (network byte order) */ | 69 | u8 value[TIPC_MEDIA_ADDR_SIZE]; |
70 | union { | 70 | u8 media_id; |
71 | __u8 eth_addr[6]; /* 48 bit Ethernet addr (byte array) */ | 71 | u8 broadcast; |
72 | } dev_addr; | ||
73 | }; | 72 | }; |
74 | 73 | ||
75 | struct tipc_bearer; | 74 | struct tipc_bearer; |
diff --git a/net/tipc/discover.c b/net/tipc/discover.c index f2fb96e86ee8..1ea2d44bbc36 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c | |||
@@ -84,7 +84,7 @@ static struct sk_buff *tipc_disc_init_msg(u32 type, | |||
84 | msg_set_non_seq(msg, 1); | 84 | msg_set_non_seq(msg, 1); |
85 | msg_set_dest_domain(msg, dest_domain); | 85 | msg_set_dest_domain(msg, dest_domain); |
86 | msg_set_bc_netid(msg, tipc_net_id); | 86 | msg_set_bc_netid(msg, tipc_net_id); |
87 | msg_set_media_addr(msg, &b_ptr->addr); | 87 | b_ptr->media->addr2msg(&b_ptr->addr, msg_media_addr(msg)); |
88 | } | 88 | } |
89 | return buf; | 89 | return buf; |
90 | } | 90 | } |
@@ -130,7 +130,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) | |||
130 | u32 type = msg_type(msg); | 130 | u32 type = msg_type(msg); |
131 | int link_fully_up; | 131 | int link_fully_up; |
132 | 132 | ||
133 | msg_get_media_addr(msg, &media_addr); | 133 | b_ptr->media->msg2addr(&media_addr, msg_media_addr(msg)); |
134 | buf_discard(buf); | 134 | buf_discard(buf); |
135 | 135 | ||
136 | /* Validate discovery message from requesting node */ | 136 | /* Validate discovery message from requesting node */ |
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index ebba0fcd937e..3b75c0d656d9 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
@@ -54,18 +54,24 @@ struct eth_bearer { | |||
54 | struct packet_type tipc_packet_type; | 54 | struct packet_type tipc_packet_type; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | static struct media eth_media_info; | ||
57 | static struct eth_bearer eth_bearers[MAX_ETH_BEARERS]; | 58 | static struct eth_bearer eth_bearers[MAX_ETH_BEARERS]; |
58 | static int eth_started; | 59 | static int eth_started; |
59 | static struct notifier_block notifier; | 60 | static struct notifier_block notifier; |
60 | 61 | ||
61 | /** | 62 | /** |
62 | * eth_media_addr_set - initialize Ethernet media address structure | 63 | * eth_media_addr_set - initialize Ethernet media address structure |
64 | * | ||
65 | * Media-dependent "value" field stores MAC address in first 6 bytes | ||
66 | * and zeroes out the remaining bytes. | ||
63 | */ | 67 | */ |
64 | 68 | ||
65 | static void eth_media_addr_set(struct tipc_media_addr *a, char *mac) | 69 | static void eth_media_addr_set(struct tipc_media_addr *a, char *mac) |
66 | { | 70 | { |
67 | a->type = htonl(TIPC_MEDIA_TYPE_ETH); | 71 | memcpy(a->value, mac, ETH_ALEN); |
68 | memcpy(&a->dev_addr.eth_addr, mac, ETH_ALEN); | 72 | memset(a->value + ETH_ALEN, 0, sizeof(a->value) - ETH_ALEN); |
73 | a->media_id = TIPC_MEDIA_TYPE_ETH; | ||
74 | a->broadcast = !memcmp(mac, eth_media_info.bcast_addr.value, ETH_ALEN); | ||
69 | } | 75 | } |
70 | 76 | ||
71 | /** | 77 | /** |
@@ -94,7 +100,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | |||
94 | 100 | ||
95 | skb_reset_network_header(clone); | 101 | skb_reset_network_header(clone); |
96 | clone->dev = dev; | 102 | clone->dev = dev; |
97 | dev_hard_header(clone, dev, ETH_P_TIPC, &dest->dev_addr.eth_addr, | 103 | dev_hard_header(clone, dev, ETH_P_TIPC, dest->value, |
98 | dev->dev_addr, clone->len); | 104 | dev->dev_addr, clone->len); |
99 | dev_queue_xmit(clone); | 105 | dev_queue_xmit(clone); |
100 | return 0; | 106 | return 0; |
@@ -256,12 +262,10 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt, | |||
256 | 262 | ||
257 | static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) | 263 | static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) |
258 | { | 264 | { |
259 | unchar *addr = (unchar *)&a->dev_addr; | ||
260 | |||
261 | if (str_size < 18) /* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */ | 265 | if (str_size < 18) /* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */ |
262 | return 1; | 266 | return 1; |
263 | 267 | ||
264 | sprintf(str_buf, "%pM", addr); | 268 | sprintf(str_buf, "%pM", a->value); |
265 | return 0; | 269 | return 0; |
266 | } | 270 | } |
267 | 271 | ||
@@ -293,7 +297,7 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area) | |||
293 | { | 297 | { |
294 | memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE); | 298 | memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE); |
295 | msg_area[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_ETH; | 299 | msg_area[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_ETH; |
296 | memcpy(msg_area + ETH_ADDR_OFFSET, a->dev_addr.eth_addr, ETH_ALEN); | 300 | memcpy(msg_area + ETH_ADDR_OFFSET, a->value, ETH_ALEN); |
297 | return 0; | 301 | return 0; |
298 | } | 302 | } |
299 | 303 | ||
@@ -322,8 +326,8 @@ static struct media eth_media_info = { | |||
322 | .str2addr = eth_str2addr, | 326 | .str2addr = eth_str2addr, |
323 | .addr2msg = eth_addr2msg, | 327 | .addr2msg = eth_addr2msg, |
324 | .msg2addr = eth_msg2addr, | 328 | .msg2addr = eth_msg2addr, |
325 | .bcast_addr = { htonl(TIPC_MEDIA_TYPE_ETH), | 329 | .bcast_addr = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, |
326 | { {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} } }, | 330 | TIPC_MEDIA_TYPE_ETH, 1 }, |
327 | .priority = TIPC_DEF_LINK_PRI, | 331 | .priority = TIPC_DEF_LINK_PRI, |
328 | .tolerance = TIPC_DEF_LINK_TOL, | 332 | .tolerance = TIPC_DEF_LINK_TOL, |
329 | .window = TIPC_DEF_LINK_WIN, | 333 | .window = TIPC_DEF_LINK_WIN, |
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 83d50967910c..3e4d3e29be61 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c | |||
@@ -333,11 +333,14 @@ void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str) | |||
333 | } | 333 | } |
334 | 334 | ||
335 | if (msg_user(msg) == LINK_CONFIG) { | 335 | if (msg_user(msg) == LINK_CONFIG) { |
336 | u32 *raw = (u32 *)msg; | 336 | struct tipc_media_addr orig; |
337 | struct tipc_media_addr *orig = (struct tipc_media_addr *)&raw[5]; | 337 | |
338 | tipc_printf(buf, ":DDOM(%x):", msg_dest_domain(msg)); | 338 | tipc_printf(buf, ":DDOM(%x):", msg_dest_domain(msg)); |
339 | tipc_printf(buf, ":NETID(%u):", msg_bc_netid(msg)); | 339 | tipc_printf(buf, ":NETID(%u):", msg_bc_netid(msg)); |
340 | tipc_media_addr_printf(buf, orig); | 340 | memcpy(orig.value, msg_media_addr(msg), sizeof(orig.value)); |
341 | orig.media_id = 0; | ||
342 | orig.broadcast = 0; | ||
343 | tipc_media_addr_printf(buf, &orig); | ||
341 | } | 344 | } |
342 | if (msg_user(msg) == BCAST_PROTOCOL) { | 345 | if (msg_user(msg) == BCAST_PROTOCOL) { |
343 | tipc_printf(buf, "BCNACK:AFTER(%u):", msg_bcgap_after(msg)); | 346 | tipc_printf(buf, "BCNACK:AFTER(%u):", msg_bcgap_after(msg)); |
diff --git a/net/tipc/msg.h b/net/tipc/msg.h index d93178f2e852..7b0cda167107 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h | |||
@@ -78,6 +78,8 @@ | |||
78 | 78 | ||
79 | #define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE) | 79 | #define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE) |
80 | 80 | ||
81 | #define TIPC_MEDIA_ADDR_OFFSET 5 | ||
82 | |||
81 | 83 | ||
82 | struct tipc_msg { | 84 | struct tipc_msg { |
83 | __be32 hdr[15]; | 85 | __be32 hdr[15]; |
@@ -682,6 +684,10 @@ static inline void msg_set_redundant_link(struct tipc_msg *m, u32 r) | |||
682 | msg_set_bits(m, 5, 12, 0x1, r); | 684 | msg_set_bits(m, 5, 12, 0x1, r); |
683 | } | 685 | } |
684 | 686 | ||
687 | static inline char *msg_media_addr(struct tipc_msg *m) | ||
688 | { | ||
689 | return (char *)&m->hdr[TIPC_MEDIA_ADDR_OFFSET]; | ||
690 | } | ||
685 | 691 | ||
686 | /* | 692 | /* |
687 | * Word 9 | 693 | * Word 9 |
@@ -734,14 +740,4 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, | |||
734 | u32 num_sect, unsigned int total_len, | 740 | u32 num_sect, unsigned int total_len, |
735 | int max_size, int usrmem, struct sk_buff **buf); | 741 | int max_size, int usrmem, struct sk_buff **buf); |
736 | 742 | ||
737 | static inline void msg_set_media_addr(struct tipc_msg *m, struct tipc_media_addr *a) | ||
738 | { | ||
739 | memcpy(&((int *)m)[5], a, sizeof(*a)); | ||
740 | } | ||
741 | |||
742 | static inline void msg_get_media_addr(struct tipc_msg *m, struct tipc_media_addr *a) | ||
743 | { | ||
744 | memcpy(a, &((int *)m)[5], sizeof(*a)); | ||
745 | } | ||
746 | |||
747 | #endif | 743 | #endif |