diff options
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/bearer.c | 18 | ||||
-rw-r--r-- | net/tipc/bearer.h | 8 | ||||
-rw-r--r-- | net/tipc/link.c | 150 |
3 files changed, 127 insertions, 49 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index aa37261626d6..b40e98adfd7f 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -65,10 +65,10 @@ static int media_name_valid(const char *name) | |||
65 | } | 65 | } |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * media_find - locates specified media object by name | 68 | * tipc_media_find - locates specified media object by name |
69 | */ | 69 | */ |
70 | 70 | ||
71 | static struct media *media_find(const char *name) | 71 | struct media *tipc_media_find(const char *name) |
72 | { | 72 | { |
73 | u32 i; | 73 | u32 i; |
74 | 74 | ||
@@ -118,7 +118,7 @@ int tipc_register_media(struct media *m_ptr) | |||
118 | goto exit; | 118 | goto exit; |
119 | if (media_count >= MAX_MEDIA) | 119 | if (media_count >= MAX_MEDIA) |
120 | goto exit; | 120 | goto exit; |
121 | if (media_find(m_ptr->name) || media_find_id(m_ptr->type_id)) | 121 | if (tipc_media_find(m_ptr->name) || media_find_id(m_ptr->type_id)) |
122 | goto exit; | 122 | goto exit; |
123 | 123 | ||
124 | media_list[media_count] = m_ptr; | 124 | media_list[media_count] = m_ptr; |
@@ -229,10 +229,10 @@ static int bearer_name_validate(const char *name, | |||
229 | } | 229 | } |
230 | 230 | ||
231 | /** | 231 | /** |
232 | * bearer_find - locates bearer object with matching bearer name | 232 | * tipc_bearer_find - locates bearer object with matching bearer name |
233 | */ | 233 | */ |
234 | 234 | ||
235 | static struct tipc_bearer *bearer_find(const char *name) | 235 | struct tipc_bearer *tipc_bearer_find(const char *name) |
236 | { | 236 | { |
237 | struct tipc_bearer *b_ptr; | 237 | struct tipc_bearer *b_ptr; |
238 | u32 i; | 238 | u32 i; |
@@ -463,7 +463,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) | |||
463 | 463 | ||
464 | write_lock_bh(&tipc_net_lock); | 464 | write_lock_bh(&tipc_net_lock); |
465 | 465 | ||
466 | m_ptr = media_find(b_name.media_name); | 466 | m_ptr = tipc_media_find(b_name.media_name); |
467 | if (!m_ptr) { | 467 | if (!m_ptr) { |
468 | warn("Bearer <%s> rejected, media <%s> not registered\n", name, | 468 | warn("Bearer <%s> rejected, media <%s> not registered\n", name, |
469 | b_name.media_name); | 469 | b_name.media_name); |
@@ -513,6 +513,8 @@ restart: | |||
513 | 513 | ||
514 | b_ptr->identity = bearer_id; | 514 | b_ptr->identity = bearer_id; |
515 | b_ptr->media = m_ptr; | 515 | b_ptr->media = m_ptr; |
516 | b_ptr->tolerance = m_ptr->tolerance; | ||
517 | b_ptr->window = m_ptr->window; | ||
516 | b_ptr->net_plane = bearer_id + 'A'; | 518 | b_ptr->net_plane = bearer_id + 'A'; |
517 | b_ptr->active = 1; | 519 | b_ptr->active = 1; |
518 | b_ptr->priority = priority; | 520 | b_ptr->priority = priority; |
@@ -546,7 +548,7 @@ int tipc_block_bearer(const char *name) | |||
546 | struct link *temp_l_ptr; | 548 | struct link *temp_l_ptr; |
547 | 549 | ||
548 | read_lock_bh(&tipc_net_lock); | 550 | read_lock_bh(&tipc_net_lock); |
549 | b_ptr = bearer_find(name); | 551 | b_ptr = tipc_bearer_find(name); |
550 | if (!b_ptr) { | 552 | if (!b_ptr) { |
551 | warn("Attempt to block unknown bearer <%s>\n", name); | 553 | warn("Attempt to block unknown bearer <%s>\n", name); |
552 | read_unlock_bh(&tipc_net_lock); | 554 | read_unlock_bh(&tipc_net_lock); |
@@ -600,7 +602,7 @@ int tipc_disable_bearer(const char *name) | |||
600 | int res; | 602 | int res; |
601 | 603 | ||
602 | write_lock_bh(&tipc_net_lock); | 604 | write_lock_bh(&tipc_net_lock); |
603 | b_ptr = bearer_find(name); | 605 | b_ptr = tipc_bearer_find(name); |
604 | if (b_ptr == NULL) { | 606 | if (b_ptr == NULL) { |
605 | warn("Attempt to disable unknown bearer <%s>\n", name); | 607 | warn("Attempt to disable unknown bearer <%s>\n", name); |
606 | res = -EINVAL; | 608 | res = -EINVAL; |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index 54a5a575d69a..cfe77c4b20f9 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
@@ -118,6 +118,8 @@ struct media { | |||
118 | * @name: bearer name (format = media:interface) | 118 | * @name: bearer name (format = media:interface) |
119 | * @media: ptr to media structure associated with bearer | 119 | * @media: ptr to media structure associated with bearer |
120 | * @priority: default link priority for bearer | 120 | * @priority: default link priority for bearer |
121 | * @window: default window size for bearer | ||
122 | * @tolerance: default link tolerance for bearer | ||
121 | * @identity: array index of this bearer within TIPC bearer array | 123 | * @identity: array index of this bearer within TIPC bearer array |
122 | * @link_req: ptr to (optional) structure making periodic link setup requests | 124 | * @link_req: ptr to (optional) structure making periodic link setup requests |
123 | * @links: list of non-congested links associated with bearer | 125 | * @links: list of non-congested links associated with bearer |
@@ -139,6 +141,8 @@ struct tipc_bearer { | |||
139 | spinlock_t lock; | 141 | spinlock_t lock; |
140 | struct media *media; | 142 | struct media *media; |
141 | u32 priority; | 143 | u32 priority; |
144 | u32 window; | ||
145 | u32 tolerance; | ||
142 | u32 identity; | 146 | u32 identity; |
143 | struct link_req *link_req; | 147 | struct link_req *link_req; |
144 | struct list_head links; | 148 | struct list_head links; |
@@ -176,6 +180,8 @@ int tipc_disable_bearer(const char *name); | |||
176 | int tipc_eth_media_start(void); | 180 | int tipc_eth_media_start(void); |
177 | void tipc_eth_media_stop(void); | 181 | void tipc_eth_media_stop(void); |
178 | 182 | ||
183 | int tipc_media_set_priority(const char *name, u32 new_value); | ||
184 | int tipc_media_set_window(const char *name, u32 new_value); | ||
179 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a); | 185 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a); |
180 | struct sk_buff *tipc_media_get_names(void); | 186 | struct sk_buff *tipc_media_get_names(void); |
181 | 187 | ||
@@ -183,7 +189,9 @@ struct sk_buff *tipc_bearer_get_names(void); | |||
183 | void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest); | 189 | void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest); |
184 | void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest); | 190 | void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest); |
185 | void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct link *l_ptr); | 191 | void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct link *l_ptr); |
192 | struct tipc_bearer *tipc_bearer_find(const char *name); | ||
186 | struct tipc_bearer *tipc_bearer_find_interface(const char *if_name); | 193 | struct tipc_bearer *tipc_bearer_find_interface(const char *if_name); |
194 | struct media *tipc_media_find(const char *name); | ||
187 | int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr, struct link *l_ptr); | 195 | int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr, struct link *l_ptr); |
188 | int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct link *l_ptr); | 196 | int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct link *l_ptr); |
189 | void tipc_bearer_stop(void); | 197 | void tipc_bearer_stop(void); |
diff --git a/net/tipc/link.c b/net/tipc/link.c index ae98a72da11a..332915e43043 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -343,7 +343,7 @@ struct link *tipc_link_create(struct tipc_node *n_ptr, | |||
343 | l_ptr->checkpoint = 1; | 343 | l_ptr->checkpoint = 1; |
344 | l_ptr->peer_session = INVALID_SESSION; | 344 | l_ptr->peer_session = INVALID_SESSION; |
345 | l_ptr->b_ptr = b_ptr; | 345 | l_ptr->b_ptr = b_ptr; |
346 | link_set_supervision_props(l_ptr, b_ptr->media->tolerance); | 346 | link_set_supervision_props(l_ptr, b_ptr->tolerance); |
347 | l_ptr->state = RESET_UNKNOWN; | 347 | l_ptr->state = RESET_UNKNOWN; |
348 | 348 | ||
349 | l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; | 349 | l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; |
@@ -355,7 +355,7 @@ struct link *tipc_link_create(struct tipc_node *n_ptr, | |||
355 | strcpy((char *)msg_data(msg), if_name); | 355 | strcpy((char *)msg_data(msg), if_name); |
356 | 356 | ||
357 | l_ptr->priority = b_ptr->priority; | 357 | l_ptr->priority = b_ptr->priority; |
358 | tipc_link_set_queue_limits(l_ptr, b_ptr->media->window); | 358 | tipc_link_set_queue_limits(l_ptr, b_ptr->window); |
359 | 359 | ||
360 | link_init_max_pkt(l_ptr); | 360 | link_init_max_pkt(l_ptr); |
361 | 361 | ||
@@ -2754,13 +2754,113 @@ static struct link *link_find_link(const char *name, struct tipc_node **node) | |||
2754 | return l_ptr; | 2754 | return l_ptr; |
2755 | } | 2755 | } |
2756 | 2756 | ||
2757 | /** | ||
2758 | * link_value_is_valid -- validate proposed link tolerance/priority/window | ||
2759 | * | ||
2760 | * @cmd - value type (TIPC_CMD_SET_LINK_*) | ||
2761 | * @new_value - the new value | ||
2762 | * | ||
2763 | * Returns 1 if value is within range, 0 if not. | ||
2764 | */ | ||
2765 | |||
2766 | static int link_value_is_valid(u16 cmd, u32 new_value) | ||
2767 | { | ||
2768 | switch (cmd) { | ||
2769 | case TIPC_CMD_SET_LINK_TOL: | ||
2770 | return (new_value >= TIPC_MIN_LINK_TOL) && | ||
2771 | (new_value <= TIPC_MAX_LINK_TOL); | ||
2772 | case TIPC_CMD_SET_LINK_PRI: | ||
2773 | return (new_value <= TIPC_MAX_LINK_PRI); | ||
2774 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2775 | return (new_value >= TIPC_MIN_LINK_WIN) && | ||
2776 | (new_value <= TIPC_MAX_LINK_WIN); | ||
2777 | } | ||
2778 | return 0; | ||
2779 | } | ||
2780 | |||
2781 | |||
2782 | /** | ||
2783 | * link_cmd_set_value - change priority/tolerance/window for link/bearer/media | ||
2784 | * @name - ptr to link, bearer, or media name | ||
2785 | * @new_value - new value of link, bearer, or media setting | ||
2786 | * @cmd - which link, bearer, or media attribute to set (TIPC_CMD_SET_LINK_*) | ||
2787 | * | ||
2788 | * Caller must hold 'tipc_net_lock' to ensure link/bearer/media is not deleted. | ||
2789 | * | ||
2790 | * Returns 0 if value updated and negative value on error. | ||
2791 | */ | ||
2792 | |||
2793 | static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | ||
2794 | { | ||
2795 | struct tipc_node *node; | ||
2796 | struct link *l_ptr; | ||
2797 | struct tipc_bearer *b_ptr; | ||
2798 | struct media *m_ptr; | ||
2799 | |||
2800 | l_ptr = link_find_link(name, &node); | ||
2801 | if (l_ptr) { | ||
2802 | /* | ||
2803 | * acquire node lock for tipc_link_send_proto_msg(). | ||
2804 | * see "TIPC locking policy" in net.c. | ||
2805 | */ | ||
2806 | tipc_node_lock(node); | ||
2807 | switch (cmd) { | ||
2808 | case TIPC_CMD_SET_LINK_TOL: | ||
2809 | link_set_supervision_props(l_ptr, new_value); | ||
2810 | tipc_link_send_proto_msg(l_ptr, | ||
2811 | STATE_MSG, 0, 0, new_value, 0, 0); | ||
2812 | break; | ||
2813 | case TIPC_CMD_SET_LINK_PRI: | ||
2814 | l_ptr->priority = new_value; | ||
2815 | tipc_link_send_proto_msg(l_ptr, | ||
2816 | STATE_MSG, 0, 0, 0, new_value, 0); | ||
2817 | break; | ||
2818 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2819 | tipc_link_set_queue_limits(l_ptr, new_value); | ||
2820 | break; | ||
2821 | } | ||
2822 | tipc_node_unlock(node); | ||
2823 | return 0; | ||
2824 | } | ||
2825 | |||
2826 | b_ptr = tipc_bearer_find(name); | ||
2827 | if (b_ptr) { | ||
2828 | switch (cmd) { | ||
2829 | case TIPC_CMD_SET_LINK_TOL: | ||
2830 | b_ptr->tolerance = new_value; | ||
2831 | return 0; | ||
2832 | case TIPC_CMD_SET_LINK_PRI: | ||
2833 | b_ptr->priority = new_value; | ||
2834 | return 0; | ||
2835 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2836 | b_ptr->window = new_value; | ||
2837 | return 0; | ||
2838 | } | ||
2839 | return -EINVAL; | ||
2840 | } | ||
2841 | |||
2842 | m_ptr = tipc_media_find(name); | ||
2843 | if (!m_ptr) | ||
2844 | return -ENODEV; | ||
2845 | switch (cmd) { | ||
2846 | case TIPC_CMD_SET_LINK_TOL: | ||
2847 | m_ptr->tolerance = new_value; | ||
2848 | return 0; | ||
2849 | case TIPC_CMD_SET_LINK_PRI: | ||
2850 | m_ptr->priority = new_value; | ||
2851 | return 0; | ||
2852 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2853 | m_ptr->window = new_value; | ||
2854 | return 0; | ||
2855 | } | ||
2856 | return -EINVAL; | ||
2857 | } | ||
2858 | |||
2757 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, | 2859 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, |
2758 | u16 cmd) | 2860 | u16 cmd) |
2759 | { | 2861 | { |
2760 | struct tipc_link_config *args; | 2862 | struct tipc_link_config *args; |
2761 | u32 new_value; | 2863 | u32 new_value; |
2762 | struct link *l_ptr; | ||
2763 | struct tipc_node *node; | ||
2764 | int res; | 2864 | int res; |
2765 | 2865 | ||
2766 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) | 2866 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) |
@@ -2769,6 +2869,10 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space | |||
2769 | args = (struct tipc_link_config *)TLV_DATA(req_tlv_area); | 2869 | args = (struct tipc_link_config *)TLV_DATA(req_tlv_area); |
2770 | new_value = ntohl(args->value); | 2870 | new_value = ntohl(args->value); |
2771 | 2871 | ||
2872 | if (!link_value_is_valid(cmd, new_value)) | ||
2873 | return tipc_cfg_reply_error_string( | ||
2874 | "cannot change, value invalid"); | ||
2875 | |||
2772 | if (!strcmp(args->name, tipc_bclink_name)) { | 2876 | if (!strcmp(args->name, tipc_bclink_name)) { |
2773 | if ((cmd == TIPC_CMD_SET_LINK_WINDOW) && | 2877 | if ((cmd == TIPC_CMD_SET_LINK_WINDOW) && |
2774 | (tipc_bclink_set_queue_limits(new_value) == 0)) | 2878 | (tipc_bclink_set_queue_limits(new_value) == 0)) |
@@ -2778,43 +2882,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space | |||
2778 | } | 2882 | } |
2779 | 2883 | ||
2780 | read_lock_bh(&tipc_net_lock); | 2884 | read_lock_bh(&tipc_net_lock); |
2781 | l_ptr = link_find_link(args->name, &node); | 2885 | res = link_cmd_set_value(args->name, new_value, cmd); |
2782 | if (!l_ptr) { | ||
2783 | read_unlock_bh(&tipc_net_lock); | ||
2784 | return tipc_cfg_reply_error_string("link not found"); | ||
2785 | } | ||
2786 | |||
2787 | tipc_node_lock(node); | ||
2788 | res = -EINVAL; | ||
2789 | switch (cmd) { | ||
2790 | case TIPC_CMD_SET_LINK_TOL: | ||
2791 | if ((new_value >= TIPC_MIN_LINK_TOL) && | ||
2792 | (new_value <= TIPC_MAX_LINK_TOL)) { | ||
2793 | link_set_supervision_props(l_ptr, new_value); | ||
2794 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, | ||
2795 | 0, 0, new_value, 0, 0); | ||
2796 | res = 0; | ||
2797 | } | ||
2798 | break; | ||
2799 | case TIPC_CMD_SET_LINK_PRI: | ||
2800 | if ((new_value >= TIPC_MIN_LINK_PRI) && | ||
2801 | (new_value <= TIPC_MAX_LINK_PRI)) { | ||
2802 | l_ptr->priority = new_value; | ||
2803 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, | ||
2804 | 0, 0, 0, new_value, 0); | ||
2805 | res = 0; | ||
2806 | } | ||
2807 | break; | ||
2808 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2809 | if ((new_value >= TIPC_MIN_LINK_WIN) && | ||
2810 | (new_value <= TIPC_MAX_LINK_WIN)) { | ||
2811 | tipc_link_set_queue_limits(l_ptr, new_value); | ||
2812 | res = 0; | ||
2813 | } | ||
2814 | break; | ||
2815 | } | ||
2816 | tipc_node_unlock(node); | ||
2817 | |||
2818 | read_unlock_bh(&tipc_net_lock); | 2886 | read_unlock_bh(&tipc_net_lock); |
2819 | if (res) | 2887 | if (res) |
2820 | return tipc_cfg_reply_error_string("cannot change link setting"); | 2888 | return tipc_cfg_reply_error_string("cannot change link setting"); |