diff options
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/addr.c | 31 | ||||
-rw-r--r-- | net/tipc/addr.h | 10 | ||||
-rw-r--r-- | net/tipc/msg.c | 2 | ||||
-rw-r--r-- | net/tipc/name_table.c | 3 | ||||
-rw-r--r-- | net/tipc/net.c | 2 | ||||
-rw-r--r-- | net/tipc/socket.c | 15 |
6 files changed, 23 insertions, 40 deletions
diff --git a/net/tipc/addr.c b/net/tipc/addr.c index 48fd3b5a73fb..97cd857d7f43 100644 --- a/net/tipc/addr.c +++ b/net/tipc/addr.c | |||
@@ -64,23 +64,6 @@ int in_own_node(struct net *net, u32 addr) | |||
64 | } | 64 | } |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * addr_domain - convert 2-bit scope value to equivalent message lookup domain | ||
68 | * | ||
69 | * Needed when address of a named message must be looked up a second time | ||
70 | * after a network hop. | ||
71 | */ | ||
72 | u32 addr_domain(struct net *net, u32 sc) | ||
73 | { | ||
74 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
75 | |||
76 | if (likely(sc == TIPC_NODE_SCOPE)) | ||
77 | return tn->own_addr; | ||
78 | if (sc == TIPC_CLUSTER_SCOPE) | ||
79 | return tipc_cluster_mask(tn->own_addr); | ||
80 | return tipc_zone_mask(tn->own_addr); | ||
81 | } | ||
82 | |||
83 | /** | ||
84 | * tipc_addr_domain_valid - validates a network domain address | 67 | * tipc_addr_domain_valid - validates a network domain address |
85 | * | 68 | * |
86 | * Accepts <Z.C.N>, <Z.C.0>, <Z.0.0>, and <0.0.0>, | 69 | * Accepts <Z.C.N>, <Z.C.0>, <Z.0.0>, and <0.0.0>, |
@@ -124,20 +107,6 @@ int tipc_in_scope(u32 domain, u32 addr) | |||
124 | return 0; | 107 | return 0; |
125 | } | 108 | } |
126 | 109 | ||
127 | /** | ||
128 | * tipc_addr_scope - convert message lookup domain to a 2-bit scope value | ||
129 | */ | ||
130 | int tipc_addr_scope(u32 domain) | ||
131 | { | ||
132 | if (likely(!domain)) | ||
133 | return TIPC_ZONE_SCOPE; | ||
134 | if (tipc_node(domain)) | ||
135 | return TIPC_NODE_SCOPE; | ||
136 | if (tipc_cluster(domain)) | ||
137 | return TIPC_CLUSTER_SCOPE; | ||
138 | return TIPC_ZONE_SCOPE; | ||
139 | } | ||
140 | |||
141 | char *tipc_addr_string_fill(char *string, u32 addr) | 110 | char *tipc_addr_string_fill(char *string, u32 addr) |
142 | { | 111 | { |
143 | snprintf(string, 16, "<%u.%u.%u>", | 112 | snprintf(string, 16, "<%u.%u.%u>", |
diff --git a/net/tipc/addr.h b/net/tipc/addr.h index bebb347803ce..2ecf5a5d40dd 100644 --- a/net/tipc/addr.h +++ b/net/tipc/addr.h | |||
@@ -60,6 +60,16 @@ static inline u32 tipc_cluster_mask(u32 addr) | |||
60 | return addr & TIPC_ZONE_CLUSTER_MASK; | 60 | return addr & TIPC_ZONE_CLUSTER_MASK; |
61 | } | 61 | } |
62 | 62 | ||
63 | static inline int tipc_node2scope(u32 node) | ||
64 | { | ||
65 | return node ? TIPC_NODE_SCOPE : TIPC_CLUSTER_SCOPE; | ||
66 | } | ||
67 | |||
68 | static inline int tipc_scope2node(struct net *net, int sc) | ||
69 | { | ||
70 | return sc != TIPC_NODE_SCOPE ? 0 : tipc_own_addr(net); | ||
71 | } | ||
72 | |||
63 | u32 tipc_own_addr(struct net *net); | 73 | u32 tipc_own_addr(struct net *net); |
64 | int in_own_cluster(struct net *net, u32 addr); | 74 | int in_own_cluster(struct net *net, u32 addr); |
65 | int in_own_cluster_exact(struct net *net, u32 addr); | 75 | int in_own_cluster_exact(struct net *net, u32 addr); |
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 4e1c6f6450bb..b6c45dccba3d 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c | |||
@@ -580,7 +580,7 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err) | |||
580 | msg = buf_msg(skb); | 580 | msg = buf_msg(skb); |
581 | if (msg_reroute_cnt(msg)) | 581 | if (msg_reroute_cnt(msg)) |
582 | return false; | 582 | return false; |
583 | dnode = addr_domain(net, msg_lookup_scope(msg)); | 583 | dnode = tipc_scope2node(net, msg_lookup_scope(msg)); |
584 | dport = tipc_nametbl_translate(net, msg_nametype(msg), | 584 | dport = tipc_nametbl_translate(net, msg_nametype(msg), |
585 | msg_nameinst(msg), &dnode); | 585 | msg_nameinst(msg), &dnode); |
586 | if (!dport) | 586 | if (!dport) |
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index e01c9c691ba2..6772390fcb00 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
@@ -473,8 +473,7 @@ struct publication *tipc_nametbl_insert_publ(struct net *net, u32 type, | |||
473 | struct name_seq *seq = nametbl_find_seq(net, type); | 473 | struct name_seq *seq = nametbl_find_seq(net, type); |
474 | int index = hash(type); | 474 | int index = hash(type); |
475 | 475 | ||
476 | if ((scope < TIPC_ZONE_SCOPE) || (scope > TIPC_NODE_SCOPE) || | 476 | if (scope > TIPC_NODE_SCOPE || lower > upper) { |
477 | (lower > upper)) { | ||
478 | pr_debug("Failed to publish illegal {%u,%u,%u} with scope %u\n", | 477 | pr_debug("Failed to publish illegal {%u,%u,%u} with scope %u\n", |
479 | type, lower, upper, scope); | 478 | type, lower, upper, scope); |
480 | return NULL; | 479 | return NULL; |
diff --git a/net/tipc/net.c b/net/tipc/net.c index 1a2fde0d6f61..5c4c4405b78e 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
@@ -118,7 +118,7 @@ int tipc_net_start(struct net *net, u32 addr) | |||
118 | tipc_sk_reinit(net); | 118 | tipc_sk_reinit(net); |
119 | 119 | ||
120 | tipc_nametbl_publish(net, TIPC_CFG_SRV, tn->own_addr, tn->own_addr, | 120 | tipc_nametbl_publish(net, TIPC_CFG_SRV, tn->own_addr, tn->own_addr, |
121 | TIPC_ZONE_SCOPE, 0, tn->own_addr); | 121 | TIPC_CLUSTER_SCOPE, 0, tn->own_addr); |
122 | 122 | ||
123 | pr_info("Started in network mode\n"); | 123 | pr_info("Started in network mode\n"); |
124 | pr_info("Own node address %s, network identity %u\n", | 124 | pr_info("Own node address %s, network identity %u\n", |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 8b04e601311c..910d3827f499 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -644,7 +644,7 @@ static int tipc_bind(struct socket *sock, struct sockaddr *uaddr, | |||
644 | goto exit; | 644 | goto exit; |
645 | } | 645 | } |
646 | 646 | ||
647 | res = (addr->scope > 0) ? | 647 | res = (addr->scope >= 0) ? |
648 | tipc_sk_publish(tsk, addr->scope, &addr->addr.nameseq) : | 648 | tipc_sk_publish(tsk, addr->scope, &addr->addr.nameseq) : |
649 | tipc_sk_withdraw(tsk, -addr->scope, &addr->addr.nameseq); | 649 | tipc_sk_withdraw(tsk, -addr->scope, &addr->addr.nameseq); |
650 | exit: | 650 | exit: |
@@ -1280,8 +1280,8 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) | |||
1280 | struct tipc_msg *hdr = &tsk->phdr; | 1280 | struct tipc_msg *hdr = &tsk->phdr; |
1281 | struct tipc_name_seq *seq; | 1281 | struct tipc_name_seq *seq; |
1282 | struct sk_buff_head pkts; | 1282 | struct sk_buff_head pkts; |
1283 | u32 type, inst, domain; | ||
1284 | u32 dnode, dport; | 1283 | u32 dnode, dport; |
1284 | u32 type, inst; | ||
1285 | int mtu, rc; | 1285 | int mtu, rc; |
1286 | 1286 | ||
1287 | if (unlikely(dlen > TIPC_MAX_USER_MSG_SIZE)) | 1287 | if (unlikely(dlen > TIPC_MAX_USER_MSG_SIZE)) |
@@ -1332,13 +1332,12 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) | |||
1332 | if (dest->addrtype == TIPC_ADDR_NAME) { | 1332 | if (dest->addrtype == TIPC_ADDR_NAME) { |
1333 | type = dest->addr.name.name.type; | 1333 | type = dest->addr.name.name.type; |
1334 | inst = dest->addr.name.name.instance; | 1334 | inst = dest->addr.name.name.instance; |
1335 | domain = dest->addr.name.domain; | 1335 | dnode = dest->addr.name.domain; |
1336 | dnode = domain; | ||
1337 | msg_set_type(hdr, TIPC_NAMED_MSG); | 1336 | msg_set_type(hdr, TIPC_NAMED_MSG); |
1338 | msg_set_hdr_sz(hdr, NAMED_H_SIZE); | 1337 | msg_set_hdr_sz(hdr, NAMED_H_SIZE); |
1339 | msg_set_nametype(hdr, type); | 1338 | msg_set_nametype(hdr, type); |
1340 | msg_set_nameinst(hdr, inst); | 1339 | msg_set_nameinst(hdr, inst); |
1341 | msg_set_lookup_scope(hdr, tipc_addr_scope(domain)); | 1340 | msg_set_lookup_scope(hdr, tipc_node2scope(dnode)); |
1342 | dport = tipc_nametbl_translate(net, type, inst, &dnode); | 1341 | dport = tipc_nametbl_translate(net, type, inst, &dnode); |
1343 | msg_set_destnode(hdr, dnode); | 1342 | msg_set_destnode(hdr, dnode); |
1344 | msg_set_destport(hdr, dport); | 1343 | msg_set_destport(hdr, dport); |
@@ -2592,6 +2591,9 @@ static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, | |||
2592 | struct publication *publ; | 2591 | struct publication *publ; |
2593 | u32 key; | 2592 | u32 key; |
2594 | 2593 | ||
2594 | if (scope != TIPC_NODE_SCOPE) | ||
2595 | scope = TIPC_CLUSTER_SCOPE; | ||
2596 | |||
2595 | if (tipc_sk_connected(sk)) | 2597 | if (tipc_sk_connected(sk)) |
2596 | return -EINVAL; | 2598 | return -EINVAL; |
2597 | key = tsk->portid + tsk->pub_count + 1; | 2599 | key = tsk->portid + tsk->pub_count + 1; |
@@ -2617,6 +2619,9 @@ static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, | |||
2617 | struct publication *safe; | 2619 | struct publication *safe; |
2618 | int rc = -EINVAL; | 2620 | int rc = -EINVAL; |
2619 | 2621 | ||
2622 | if (scope != TIPC_NODE_SCOPE) | ||
2623 | scope = TIPC_CLUSTER_SCOPE; | ||
2624 | |||
2620 | list_for_each_entry_safe(publ, safe, &tsk->publications, pport_list) { | 2625 | list_for_each_entry_safe(publ, safe, &tsk->publications, pport_list) { |
2621 | if (seq) { | 2626 | if (seq) { |
2622 | if (publ->scope != scope) | 2627 | if (publ->scope != scope) |