diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2011-11-02 15:49:40 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2012-02-24 17:05:14 -0500 |
commit | c422f1bdc3d3f9f637b3d288a6601668e26111d6 (patch) | |
tree | d3e810de3eb96a19afb65c6605af5e00620e3316 /net/tipc | |
parent | c74a46110fd5f97bf9299e68e9ed0453bdacb181 (diff) |
tipc: Simplify enforcement of reserved name type prohibition
Streamlines the logic that prevents an application from binding a
reserved TIPC name type to a port by moving the check to the code
that handles a socket bind() operation. This allows internal TIPC
subsystems to bind a reserved name without having to set an atomic
flag to gain permission to use such a name. (This simplification is
now possible due to the elimination of support for TIPC's native API.)
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/config.c | 2 | ||||
-rw-r--r-- | net/tipc/name_table.c | 24 | ||||
-rw-r--r-- | net/tipc/name_table.h | 2 | ||||
-rw-r--r-- | net/tipc/socket.c | 3 | ||||
-rw-r--r-- | net/tipc/subscr.c | 2 |
5 files changed, 6 insertions, 27 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c index 4785bf26cdf4..9fefd32e9b2e 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
@@ -481,7 +481,7 @@ int tipc_cfg_init(void) | |||
481 | 481 | ||
482 | seq.type = TIPC_CFG_SRV; | 482 | seq.type = TIPC_CFG_SRV; |
483 | seq.lower = seq.upper = tipc_own_addr; | 483 | seq.lower = seq.upper = tipc_own_addr; |
484 | res = tipc_nametbl_publish_rsv(config_port_ref, TIPC_ZONE_SCOPE, &seq); | 484 | res = tipc_publish(config_port_ref, TIPC_ZONE_SCOPE, &seq); |
485 | if (res) | 485 | if (res) |
486 | goto failed; | 486 | goto failed; |
487 | 487 | ||
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 89eb5621ebba..1196f050e334 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
@@ -114,10 +114,8 @@ struct name_table { | |||
114 | }; | 114 | }; |
115 | 115 | ||
116 | static struct name_table table; | 116 | static struct name_table table; |
117 | static atomic_t rsv_publ_ok = ATOMIC_INIT(0); | ||
118 | DEFINE_RWLOCK(tipc_nametbl_lock); | 117 | DEFINE_RWLOCK(tipc_nametbl_lock); |
119 | 118 | ||
120 | |||
121 | static int hash(int x) | 119 | static int hash(int x) |
122 | { | 120 | { |
123 | return x & (tipc_nametbl_size - 1); | 121 | return x & (tipc_nametbl_size - 1); |
@@ -665,22 +663,7 @@ exit: | |||
665 | return res; | 663 | return res; |
666 | } | 664 | } |
667 | 665 | ||
668 | /** | 666 | /* |
669 | * tipc_nametbl_publish_rsv - publish port name using a reserved name type | ||
670 | */ | ||
671 | |||
672 | int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope, | ||
673 | struct tipc_name_seq const *seq) | ||
674 | { | ||
675 | int res; | ||
676 | |||
677 | atomic_inc(&rsv_publ_ok); | ||
678 | res = tipc_publish(ref, scope, seq); | ||
679 | atomic_dec(&rsv_publ_ok); | ||
680 | return res; | ||
681 | } | ||
682 | |||
683 | /** | ||
684 | * tipc_nametbl_publish - add name publication to network name tables | 667 | * tipc_nametbl_publish - add name publication to network name tables |
685 | */ | 668 | */ |
686 | 669 | ||
@@ -694,11 +677,6 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | |||
694 | tipc_max_publications); | 677 | tipc_max_publications); |
695 | return NULL; | 678 | return NULL; |
696 | } | 679 | } |
697 | if ((type < TIPC_RESERVED_TYPES) && !atomic_read(&rsv_publ_ok)) { | ||
698 | warn("Publication failed, reserved name {%u,%u,%u}\n", | ||
699 | type, lower, upper); | ||
700 | return NULL; | ||
701 | } | ||
702 | 680 | ||
703 | write_lock_bh(&tipc_nametbl_lock); | 681 | write_lock_bh(&tipc_nametbl_lock); |
704 | table.local_publ_count++; | 682 | table.local_publ_count++; |
diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h index 8086b42f92ad..207d59ebf849 100644 --- a/net/tipc/name_table.h +++ b/net/tipc/name_table.h | |||
@@ -91,8 +91,6 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space); | |||
91 | u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node); | 91 | u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node); |
92 | int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, | 92 | int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, |
93 | struct tipc_port_list *dports); | 93 | struct tipc_port_list *dports); |
94 | int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope, | ||
95 | struct tipc_name_seq const *seq); | ||
96 | struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | 94 | struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, |
97 | u32 scope, u32 port_ref, u32 key); | 95 | u32 scope, u32 port_ref, u32 key); |
98 | int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key); | 96 | int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key); |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index e2f7c5d370ba..d3227f2a216e 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -355,6 +355,9 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len) | |||
355 | else if (addr->addrtype != TIPC_ADDR_NAMESEQ) | 355 | else if (addr->addrtype != TIPC_ADDR_NAMESEQ) |
356 | return -EAFNOSUPPORT; | 356 | return -EAFNOSUPPORT; |
357 | 357 | ||
358 | if (addr->addr.nameseq.type < TIPC_RESERVED_TYPES) | ||
359 | return -EACCES; | ||
360 | |||
358 | return (addr->scope > 0) ? | 361 | return (addr->scope > 0) ? |
359 | tipc_publish(portref, addr->scope, &addr->addr.nameseq) : | 362 | tipc_publish(portref, addr->scope, &addr->addr.nameseq) : |
360 | tipc_withdraw(portref, -addr->scope, &addr->addr.nameseq); | 363 | tipc_withdraw(portref, -addr->scope, &addr->addr.nameseq); |
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index 8c49566da8f3..b2964e9895d3 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
@@ -552,7 +552,7 @@ int tipc_subscr_start(void) | |||
552 | if (res) | 552 | if (res) |
553 | goto failed; | 553 | goto failed; |
554 | 554 | ||
555 | res = tipc_nametbl_publish_rsv(topsrv.setup_port, TIPC_NODE_SCOPE, &seq); | 555 | res = tipc_publish(topsrv.setup_port, TIPC_NODE_SCOPE, &seq); |
556 | if (res) { | 556 | if (res) { |
557 | tipc_deleteport(topsrv.setup_port); | 557 | tipc_deleteport(topsrv.setup_port); |
558 | topsrv.setup_port = 0; | 558 | topsrv.setup_port = 0; |