diff options
Diffstat (limited to 'net/tipc')
| -rw-r--r-- | net/tipc/Kconfig | 75 | ||||
| -rw-r--r-- | net/tipc/addr.c | 32 | ||||
| -rw-r--r-- | net/tipc/addr.h | 37 | ||||
| -rw-r--r-- | net/tipc/bcast.c | 149 | ||||
| -rw-r--r-- | net/tipc/bcast.h | 117 | ||||
| -rw-r--r-- | net/tipc/bearer.c | 53 | ||||
| -rw-r--r-- | net/tipc/bearer.h | 18 | ||||
| -rw-r--r-- | net/tipc/cluster.c | 2 | ||||
| -rw-r--r-- | net/tipc/config.c | 68 | ||||
| -rw-r--r-- | net/tipc/core.c | 36 | ||||
| -rw-r--r-- | net/tipc/core.h | 28 | ||||
| -rw-r--r-- | net/tipc/discover.c | 8 | ||||
| -rw-r--r-- | net/tipc/eth_media.c | 1 | ||||
| -rw-r--r-- | net/tipc/link.c | 111 | ||||
| -rw-r--r-- | net/tipc/link.h | 35 | ||||
| -rw-r--r-- | net/tipc/msg.c | 94 | ||||
| -rw-r--r-- | net/tipc/msg.h | 99 | ||||
| -rw-r--r-- | net/tipc/name_distr.c | 2 | ||||
| -rw-r--r-- | net/tipc/name_table.c | 2 | ||||
| -rw-r--r-- | net/tipc/net.c | 31 | ||||
| -rw-r--r-- | net/tipc/node.c | 14 | ||||
| -rw-r--r-- | net/tipc/port.c | 27 | ||||
| -rw-r--r-- | net/tipc/port.h | 2 | ||||
| -rw-r--r-- | net/tipc/ref.c | 26 | ||||
| -rw-r--r-- | net/tipc/socket.c | 34 | ||||
| -rw-r--r-- | net/tipc/subscr.c | 68 | ||||
| -rw-r--r-- | net/tipc/subscr.h | 2 |
27 files changed, 583 insertions, 588 deletions
diff --git a/net/tipc/Kconfig b/net/tipc/Kconfig index 3b30d1130b61..b74f78d0c033 100644 --- a/net/tipc/Kconfig +++ b/net/tipc/Kconfig | |||
| @@ -10,7 +10,7 @@ menuconfig TIPC | |||
| 10 | specially designed for intra cluster communication. This protocol | 10 | specially designed for intra cluster communication. This protocol |
| 11 | originates from Ericsson where it has been used in carrier grade | 11 | originates from Ericsson where it has been used in carrier grade |
| 12 | cluster applications for many years. | 12 | cluster applications for many years. |
| 13 | 13 | ||
| 14 | For more information about TIPC, see http://tipc.sourceforge.net. | 14 | For more information about TIPC, see http://tipc.sourceforge.net. |
| 15 | 15 | ||
| 16 | This protocol support is also available as a module ( = code which | 16 | This protocol support is also available as a module ( = code which |
| @@ -23,91 +23,76 @@ menuconfig TIPC | |||
| 23 | if TIPC | 23 | if TIPC |
| 24 | 24 | ||
| 25 | config TIPC_ADVANCED | 25 | config TIPC_ADVANCED |
| 26 | bool "TIPC: Advanced configuration" | 26 | bool "Advanced TIPC configuration" |
| 27 | default n | 27 | default n |
| 28 | help | 28 | help |
| 29 | Saying Y here will open some advanced configuration | 29 | Saying Y here will open some advanced configuration for TIPC. |
| 30 | for TIPC. Most users do not need to bother, so if | 30 | Most users do not need to bother; if unsure, just say N. |
| 31 | unsure, just say N. | ||
| 32 | 31 | ||
| 33 | config TIPC_ZONES | 32 | config TIPC_ZONES |
| 34 | int "Maximum number of zones in network" | 33 | int "Maximum number of zones in a network" |
| 35 | depends on TIPC_ADVANCED | 34 | depends on TIPC_ADVANCED |
| 35 | range 1 255 | ||
| 36 | default "3" | 36 | default "3" |
| 37 | help | 37 | help |
| 38 | Max number of zones inside TIPC network. Max supported value | 38 | Specifies how many zones can be supported in a TIPC network. |
| 39 | is 255 zones, minimum is 1 | 39 | Can range from 1 to 255 zones; default is 3. |
| 40 | 40 | ||
| 41 | Default is 3 zones in a network; setting this to higher | 41 | Setting this to a smaller value saves some memory; |
| 42 | allows more zones but might use more memory. | 42 | setting it to a higher value allows for more zones. |
| 43 | 43 | ||
| 44 | config TIPC_CLUSTERS | 44 | config TIPC_CLUSTERS |
| 45 | int "Maximum number of clusters in a zone" | 45 | int "Maximum number of clusters in a zone" |
| 46 | depends on TIPC_ADVANCED | 46 | depends on TIPC_ADVANCED |
| 47 | range 1 1 | ||
| 47 | default "1" | 48 | default "1" |
| 48 | help | 49 | help |
| 49 | ***Only 1 (one cluster in a zone) is supported by current code. | 50 | Specifies how many clusters can be supported in a TIPC zone. |
| 50 | Any value set here will be overridden.*** | ||
| 51 | |||
| 52 | (Max number of clusters inside TIPC zone. Max supported | ||
| 53 | value is 4095 clusters, minimum is 1. | ||
| 54 | 51 | ||
| 55 | Default is 1; setting this to smaller value might save | 52 | *** Currently TIPC only supports a single cluster per zone. *** |
| 56 | some memory, setting it to higher | ||
| 57 | allows more clusters and might consume more memory.) | ||
| 58 | 53 | ||
| 59 | config TIPC_NODES | 54 | config TIPC_NODES |
| 60 | int "Maximum number of nodes in cluster" | 55 | int "Maximum number of nodes in a cluster" |
| 61 | depends on TIPC_ADVANCED | 56 | depends on TIPC_ADVANCED |
| 57 | range 8 2047 | ||
| 62 | default "255" | 58 | default "255" |
| 63 | help | 59 | help |
| 64 | Maximum number of nodes inside a TIPC cluster. Maximum | 60 | Specifies how many nodes can be supported in a TIPC cluster. |
| 65 | supported value is 2047 nodes, minimum is 8. | 61 | Can range from 8 to 2047 nodes; default is 255. |
| 66 | |||
| 67 | Setting this to a smaller value saves some memory, | ||
| 68 | setting it to higher allows more nodes. | ||
| 69 | |||
| 70 | config TIPC_SLAVE_NODES | ||
| 71 | int "Maximum number of slave nodes in cluster" | ||
| 72 | depends on TIPC_ADVANCED | ||
| 73 | default "0" | ||
| 74 | help | ||
| 75 | ***This capability is not supported by current code.*** | ||
| 76 | |||
| 77 | Maximum number of slave nodes inside a TIPC cluster. Maximum | ||
| 78 | supported value is 2047 nodes, minimum is 0. | ||
| 79 | 62 | ||
| 80 | Setting this to a smaller value saves some memory, | 63 | Setting this to a smaller value saves some memory; |
| 81 | setting it to higher allows more nodes. | 64 | setting it to higher allows for more nodes. |
| 82 | 65 | ||
| 83 | config TIPC_PORTS | 66 | config TIPC_PORTS |
| 84 | int "Maximum number of ports in a node" | 67 | int "Maximum number of ports in a node" |
| 85 | depends on TIPC_ADVANCED | 68 | depends on TIPC_ADVANCED |
| 69 | range 127 65535 | ||
| 86 | default "8191" | 70 | default "8191" |
| 87 | help | 71 | help |
| 88 | Maximum number of ports within a node. Maximum | 72 | Specifies how many ports can be supported by a node. |
| 89 | supported value is 64535 nodes, minimum is 127. | 73 | Can range from 127 to 65535 ports; default is 8191. |
| 90 | 74 | ||
| 91 | Setting this to a smaller value saves some memory, | 75 | Setting this to a smaller value saves some memory, |
| 92 | setting it to higher allows more ports. | 76 | setting it to higher allows for more ports. |
| 93 | 77 | ||
| 94 | config TIPC_LOG | 78 | config TIPC_LOG |
| 95 | int "Size of log buffer" | 79 | int "Size of log buffer" |
| 96 | depends on TIPC_ADVANCED | 80 | depends on TIPC_ADVANCED |
| 97 | default 0 | 81 | range 0 32768 |
| 82 | default "0" | ||
| 98 | help | 83 | help |
| 99 | Size (in bytes) of TIPC's internal log buffer, which records the | 84 | Size (in bytes) of TIPC's internal log buffer, which records the |
| 100 | occurrence of significant events. Maximum supported value | 85 | occurrence of significant events. Can range from 0 to 32768 bytes; |
| 101 | is 32768 bytes, minimum is 0. | 86 | default is 0. |
| 102 | 87 | ||
| 103 | There is no need to enable the log buffer unless the node will be | 88 | There is no need to enable the log buffer unless the node will be |
| 104 | managed remotely via TIPC. | 89 | managed remotely via TIPC. |
| 105 | 90 | ||
| 106 | config TIPC_DEBUG | 91 | config TIPC_DEBUG |
| 107 | bool "Enable debugging support" | 92 | bool "Enable debug messages" |
| 108 | default n | 93 | default n |
| 109 | help | 94 | help |
| 110 | This will enable debugging of TIPC. | 95 | This enables debugging of TIPC. |
| 111 | 96 | ||
| 112 | Only say Y here if you are having trouble with TIPC. It will | 97 | Only say Y here if you are having trouble with TIPC. It will |
| 113 | enable the display of detailed information about what is going on. | 98 | enable the display of detailed information about what is going on. |
diff --git a/net/tipc/addr.c b/net/tipc/addr.c index e5207a11edf6..c048543ffbeb 100644 --- a/net/tipc/addr.c +++ b/net/tipc/addr.c | |||
| @@ -92,3 +92,35 @@ int tipc_addr_node_valid(u32 addr) | |||
| 92 | return (tipc_addr_domain_valid(addr) && tipc_node(addr)); | 92 | return (tipc_addr_domain_valid(addr) && tipc_node(addr)); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | int tipc_in_scope(u32 domain, u32 addr) | ||
| 96 | { | ||
| 97 | if (!domain || (domain == addr)) | ||
| 98 | return 1; | ||
| 99 | if (domain == (addr & 0xfffff000u)) /* domain <Z.C.0> */ | ||
| 100 | return 1; | ||
| 101 | if (domain == (addr & 0xff000000u)) /* domain <Z.0.0> */ | ||
| 102 | return 1; | ||
| 103 | return 0; | ||
| 104 | } | ||
| 105 | |||
| 106 | /** | ||
| 107 | * tipc_addr_scope - convert message lookup domain to a 2-bit scope value | ||
| 108 | */ | ||
| 109 | |||
| 110 | int tipc_addr_scope(u32 domain) | ||
| 111 | { | ||
| 112 | if (likely(!domain)) | ||
| 113 | return TIPC_ZONE_SCOPE; | ||
| 114 | if (tipc_node(domain)) | ||
| 115 | return TIPC_NODE_SCOPE; | ||
| 116 | if (tipc_cluster(domain)) | ||
| 117 | return TIPC_CLUSTER_SCOPE; | ||
| 118 | return TIPC_ZONE_SCOPE; | ||
| 119 | } | ||
| 120 | |||
| 121 | char *tipc_addr_string_fill(char *string, u32 addr) | ||
| 122 | { | ||
| 123 | snprintf(string, 16, "<%u.%u.%u>", | ||
| 124 | tipc_zone(addr), tipc_cluster(addr), tipc_node(addr)); | ||
| 125 | return string; | ||
| 126 | } | ||
diff --git a/net/tipc/addr.h b/net/tipc/addr.h index 3ba67e6ce03e..c1cc5724d8cc 100644 --- a/net/tipc/addr.h +++ b/net/tipc/addr.h | |||
| @@ -67,32 +67,6 @@ static inline int may_route(u32 addr) | |||
| 67 | return(addr ^ tipc_own_addr) >> 11; | 67 | return(addr ^ tipc_own_addr) >> 11; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | static inline int in_scope(u32 domain, u32 addr) | ||
| 71 | { | ||
| 72 | if (!domain || (domain == addr)) | ||
| 73 | return 1; | ||
| 74 | if (domain == (addr & 0xfffff000u)) /* domain <Z.C.0> */ | ||
| 75 | return 1; | ||
| 76 | if (domain == (addr & 0xff000000u)) /* domain <Z.0.0> */ | ||
| 77 | return 1; | ||
| 78 | return 0; | ||
| 79 | } | ||
| 80 | |||
| 81 | /** | ||
| 82 | * addr_scope - convert message lookup domain to equivalent 2-bit scope value | ||
| 83 | */ | ||
| 84 | |||
| 85 | static inline int addr_scope(u32 domain) | ||
| 86 | { | ||
| 87 | if (likely(!domain)) | ||
| 88 | return TIPC_ZONE_SCOPE; | ||
| 89 | if (tipc_node(domain)) | ||
| 90 | return TIPC_NODE_SCOPE; | ||
| 91 | if (tipc_cluster(domain)) | ||
| 92 | return TIPC_CLUSTER_SCOPE; | ||
| 93 | return TIPC_ZONE_SCOPE; | ||
| 94 | } | ||
| 95 | |||
| 96 | /** | 70 | /** |
| 97 | * addr_domain - convert 2-bit scope value to equivalent message lookup domain | 71 | * addr_domain - convert 2-bit scope value to equivalent message lookup domain |
| 98 | * | 72 | * |
| @@ -110,14 +84,9 @@ static inline int addr_domain(int sc) | |||
| 110 | return tipc_addr(tipc_zone(tipc_own_addr), 0, 0); | 84 | return tipc_addr(tipc_zone(tipc_own_addr), 0, 0); |
| 111 | } | 85 | } |
| 112 | 86 | ||
| 113 | static inline char *addr_string_fill(char *string, u32 addr) | ||
| 114 | { | ||
| 115 | snprintf(string, 16, "<%u.%u.%u>", | ||
| 116 | tipc_zone(addr), tipc_cluster(addr), tipc_node(addr)); | ||
| 117 | return string; | ||
| 118 | } | ||
| 119 | |||
| 120 | int tipc_addr_domain_valid(u32); | 87 | int tipc_addr_domain_valid(u32); |
| 121 | int tipc_addr_node_valid(u32 addr); | 88 | int tipc_addr_node_valid(u32 addr); |
| 122 | 89 | int tipc_in_scope(u32 domain, u32 addr); | |
| 90 | int tipc_addr_scope(u32 domain); | ||
| 91 | char *tipc_addr_string_fill(char *string, u32 addr); | ||
| 123 | #endif | 92 | #endif |
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index a3bfd4064912..a008c6689305 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
| @@ -119,7 +119,7 @@ static struct bclink *bclink = NULL; | |||
| 119 | static struct link *bcl = NULL; | 119 | static struct link *bcl = NULL; |
| 120 | static DEFINE_SPINLOCK(bc_lock); | 120 | static DEFINE_SPINLOCK(bc_lock); |
| 121 | 121 | ||
| 122 | const char tipc_bclink_name[] = "multicast-link"; | 122 | const char tipc_bclink_name[] = "broadcast-link"; |
| 123 | 123 | ||
| 124 | 124 | ||
| 125 | static u32 buf_seqno(struct sk_buff *buf) | 125 | static u32 buf_seqno(struct sk_buff *buf) |
| @@ -275,7 +275,7 @@ static void bclink_send_nack(struct tipc_node *n_ptr) | |||
| 275 | buf = buf_acquire(INT_H_SIZE); | 275 | buf = buf_acquire(INT_H_SIZE); |
| 276 | if (buf) { | 276 | if (buf) { |
| 277 | msg = buf_msg(buf); | 277 | msg = buf_msg(buf); |
| 278 | msg_init(msg, BCAST_PROTOCOL, STATE_MSG, | 278 | tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG, |
| 279 | INT_H_SIZE, n_ptr->addr); | 279 | INT_H_SIZE, n_ptr->addr); |
| 280 | msg_set_mc_netid(msg, tipc_net_id); | 280 | msg_set_mc_netid(msg, tipc_net_id); |
| 281 | msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in)); | 281 | msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in)); |
| @@ -558,10 +558,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf, | |||
| 558 | struct tipc_bearer *unused1, | 558 | struct tipc_bearer *unused1, |
| 559 | struct tipc_media_addr *unused2) | 559 | struct tipc_media_addr *unused2) |
| 560 | { | 560 | { |
| 561 | static int send_count = 0; | ||
| 562 | |||
| 563 | int bp_index; | 561 | int bp_index; |
| 564 | int swap_time; | ||
| 565 | 562 | ||
| 566 | /* Prepare buffer for broadcasting (if first time trying to send it) */ | 563 | /* Prepare buffer for broadcasting (if first time trying to send it) */ |
| 567 | 564 | ||
| @@ -575,11 +572,6 @@ static int tipc_bcbearer_send(struct sk_buff *buf, | |||
| 575 | msg_set_mc_netid(msg, tipc_net_id); | 572 | msg_set_mc_netid(msg, tipc_net_id); |
| 576 | } | 573 | } |
| 577 | 574 | ||
| 578 | /* Determine if bearer pairs should be swapped following this attempt */ | ||
| 579 | |||
| 580 | if ((swap_time = (++send_count >= 10))) | ||
| 581 | send_count = 0; | ||
| 582 | |||
| 583 | /* Send buffer over bearers until all targets reached */ | 575 | /* Send buffer over bearers until all targets reached */ |
| 584 | 576 | ||
| 585 | bcbearer->remains = tipc_cltr_bcast_nodes; | 577 | bcbearer->remains = tipc_cltr_bcast_nodes; |
| @@ -595,21 +587,22 @@ static int tipc_bcbearer_send(struct sk_buff *buf, | |||
| 595 | if (bcbearer->remains_new.count == bcbearer->remains.count) | 587 | if (bcbearer->remains_new.count == bcbearer->remains.count) |
| 596 | continue; /* bearer pair doesn't add anything */ | 588 | continue; /* bearer pair doesn't add anything */ |
| 597 | 589 | ||
| 598 | if (!p->publ.blocked && | 590 | if (p->publ.blocked || |
| 599 | !p->media->send_msg(buf, &p->publ, &p->media->bcast_addr)) { | 591 | p->media->send_msg(buf, &p->publ, &p->media->bcast_addr)) { |
| 600 | if (swap_time && s && !s->publ.blocked) | 592 | /* unable to send on primary bearer */ |
| 601 | goto swap; | 593 | if (!s || s->publ.blocked || |
| 602 | else | 594 | s->media->send_msg(buf, &s->publ, |
| 603 | goto update; | 595 | &s->media->bcast_addr)) { |
| 596 | /* unable to send on either bearer */ | ||
| 597 | continue; | ||
| 598 | } | ||
| 599 | } | ||
| 600 | |||
| 601 | if (s) { | ||
| 602 | bcbearer->bpairs[bp_index].primary = s; | ||
| 603 | bcbearer->bpairs[bp_index].secondary = p; | ||
| 604 | } | 604 | } |
| 605 | 605 | ||
| 606 | if (!s || s->publ.blocked || | ||
| 607 | s->media->send_msg(buf, &s->publ, &s->media->bcast_addr)) | ||
| 608 | continue; /* unable to send using bearer pair */ | ||
| 609 | swap: | ||
| 610 | bcbearer->bpairs[bp_index].primary = s; | ||
| 611 | bcbearer->bpairs[bp_index].secondary = p; | ||
| 612 | update: | ||
| 613 | if (bcbearer->remains_new.count == 0) | 606 | if (bcbearer->remains_new.count == 0) |
| 614 | return 0; | 607 | return 0; |
| 615 | 608 | ||
| @@ -829,3 +822,113 @@ void tipc_bclink_stop(void) | |||
| 829 | spin_unlock_bh(&bc_lock); | 822 | spin_unlock_bh(&bc_lock); |
| 830 | } | 823 | } |
| 831 | 824 | ||
| 825 | |||
| 826 | /** | ||
| 827 | * tipc_nmap_add - add a node to a node map | ||
| 828 | */ | ||
| 829 | |||
| 830 | void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node) | ||
| 831 | { | ||
| 832 | int n = tipc_node(node); | ||
| 833 | int w = n / WSIZE; | ||
| 834 | u32 mask = (1 << (n % WSIZE)); | ||
| 835 | |||
| 836 | if ((nm_ptr->map[w] & mask) == 0) { | ||
| 837 | nm_ptr->count++; | ||
| 838 | nm_ptr->map[w] |= mask; | ||
| 839 | } | ||
| 840 | } | ||
| 841 | |||
| 842 | /** | ||
| 843 | * tipc_nmap_remove - remove a node from a node map | ||
| 844 | */ | ||
| 845 | |||
| 846 | void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node) | ||
| 847 | { | ||
| 848 | int n = tipc_node(node); | ||
| 849 | int w = n / WSIZE; | ||
| 850 | u32 mask = (1 << (n % WSIZE)); | ||
| 851 | |||
| 852 | if ((nm_ptr->map[w] & mask) != 0) { | ||
| 853 | nm_ptr->map[w] &= ~mask; | ||
| 854 | nm_ptr->count--; | ||
| 855 | } | ||
| 856 | } | ||
| 857 | |||
| 858 | /** | ||
| 859 | * tipc_nmap_diff - find differences between node maps | ||
| 860 | * @nm_a: input node map A | ||
| 861 | * @nm_b: input node map B | ||
| 862 | * @nm_diff: output node map A-B (i.e. nodes of A that are not in B) | ||
| 863 | */ | ||
| 864 | |||
| 865 | void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b, | ||
| 866 | struct tipc_node_map *nm_diff) | ||
| 867 | { | ||
| 868 | int stop = ARRAY_SIZE(nm_a->map); | ||
| 869 | int w; | ||
| 870 | int b; | ||
| 871 | u32 map; | ||
| 872 | |||
| 873 | memset(nm_diff, 0, sizeof(*nm_diff)); | ||
| 874 | for (w = 0; w < stop; w++) { | ||
| 875 | map = nm_a->map[w] ^ (nm_a->map[w] & nm_b->map[w]); | ||
| 876 | nm_diff->map[w] = map; | ||
| 877 | if (map != 0) { | ||
| 878 | for (b = 0 ; b < WSIZE; b++) { | ||
| 879 | if (map & (1 << b)) | ||
| 880 | nm_diff->count++; | ||
| 881 | } | ||
| 882 | } | ||
| 883 | } | ||
| 884 | } | ||
| 885 | |||
| 886 | /** | ||
| 887 | * tipc_port_list_add - add a port to a port list, ensuring no duplicates | ||
| 888 | */ | ||
| 889 | |||
| 890 | void tipc_port_list_add(struct port_list *pl_ptr, u32 port) | ||
| 891 | { | ||
| 892 | struct port_list *item = pl_ptr; | ||
| 893 | int i; | ||
| 894 | int item_sz = PLSIZE; | ||
| 895 | int cnt = pl_ptr->count; | ||
| 896 | |||
| 897 | for (; ; cnt -= item_sz, item = item->next) { | ||
| 898 | if (cnt < PLSIZE) | ||
| 899 | item_sz = cnt; | ||
| 900 | for (i = 0; i < item_sz; i++) | ||
| 901 | if (item->ports[i] == port) | ||
| 902 | return; | ||
| 903 | if (i < PLSIZE) { | ||
| 904 | item->ports[i] = port; | ||
| 905 | pl_ptr->count++; | ||
| 906 | return; | ||
| 907 | } | ||
| 908 | if (!item->next) { | ||
| 909 | item->next = kmalloc(sizeof(*item), GFP_ATOMIC); | ||
| 910 | if (!item->next) { | ||
| 911 | warn("Incomplete multicast delivery, no memory\n"); | ||
| 912 | return; | ||
| 913 | } | ||
| 914 | item->next->next = NULL; | ||
| 915 | } | ||
| 916 | } | ||
| 917 | } | ||
| 918 | |||
| 919 | /** | ||
| 920 | * tipc_port_list_free - free dynamically created entries in port_list chain | ||
| 921 | * | ||
| 922 | */ | ||
| 923 | |||
| 924 | void tipc_port_list_free(struct port_list *pl_ptr) | ||
| 925 | { | ||
| 926 | struct port_list *item; | ||
| 927 | struct port_list *next; | ||
| 928 | |||
| 929 | for (item = pl_ptr->next; item; item = next) { | ||
| 930 | next = item->next; | ||
| 931 | kfree(item); | ||
| 932 | } | ||
| 933 | } | ||
| 934 | |||
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h index 4c1771e95c99..e8c2b81658c7 100644 --- a/net/tipc/bcast.h +++ b/net/tipc/bcast.h | |||
| @@ -72,41 +72,11 @@ struct tipc_node; | |||
| 72 | 72 | ||
| 73 | extern const char tipc_bclink_name[]; | 73 | extern const char tipc_bclink_name[]; |
| 74 | 74 | ||
| 75 | void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node); | ||
| 76 | void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node); | ||
| 75 | 77 | ||
| 76 | /** | 78 | /** |
| 77 | * nmap_add - add a node to a node map | 79 | * tipc_nmap_equal - test for equality of node maps |
| 78 | */ | ||
| 79 | |||
| 80 | static inline void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node) | ||
| 81 | { | ||
| 82 | int n = tipc_node(node); | ||
| 83 | int w = n / WSIZE; | ||
| 84 | u32 mask = (1 << (n % WSIZE)); | ||
| 85 | |||
| 86 | if ((nm_ptr->map[w] & mask) == 0) { | ||
| 87 | nm_ptr->count++; | ||
| 88 | nm_ptr->map[w] |= mask; | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | /** | ||
| 93 | * nmap_remove - remove a node from a node map | ||
| 94 | */ | ||
| 95 | |||
| 96 | static inline void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node) | ||
| 97 | { | ||
| 98 | int n = tipc_node(node); | ||
| 99 | int w = n / WSIZE; | ||
| 100 | u32 mask = (1 << (n % WSIZE)); | ||
| 101 | |||
| 102 | if ((nm_ptr->map[w] & mask) != 0) { | ||
| 103 | nm_ptr->map[w] &= ~mask; | ||
| 104 | nm_ptr->count--; | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | /** | ||
| 109 | * nmap_equal - test for equality of node maps | ||
| 110 | */ | 80 | */ |
| 111 | 81 | ||
| 112 | static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b) | 82 | static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b) |
| @@ -114,84 +84,11 @@ static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_m | |||
| 114 | return !memcmp(nm_a, nm_b, sizeof(*nm_a)); | 84 | return !memcmp(nm_a, nm_b, sizeof(*nm_a)); |
| 115 | } | 85 | } |
| 116 | 86 | ||
| 117 | /** | 87 | void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b, |
| 118 | * nmap_diff - find differences between node maps | 88 | struct tipc_node_map *nm_diff); |
| 119 | * @nm_a: input node map A | ||
| 120 | * @nm_b: input node map B | ||
| 121 | * @nm_diff: output node map A-B (i.e. nodes of A that are not in B) | ||
| 122 | */ | ||
| 123 | |||
| 124 | static inline void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b, | ||
| 125 | struct tipc_node_map *nm_diff) | ||
| 126 | { | ||
| 127 | int stop = ARRAY_SIZE(nm_a->map); | ||
| 128 | int w; | ||
| 129 | int b; | ||
| 130 | u32 map; | ||
| 131 | |||
| 132 | memset(nm_diff, 0, sizeof(*nm_diff)); | ||
| 133 | for (w = 0; w < stop; w++) { | ||
| 134 | map = nm_a->map[w] ^ (nm_a->map[w] & nm_b->map[w]); | ||
| 135 | nm_diff->map[w] = map; | ||
| 136 | if (map != 0) { | ||
| 137 | for (b = 0 ; b < WSIZE; b++) { | ||
| 138 | if (map & (1 << b)) | ||
| 139 | nm_diff->count++; | ||
| 140 | } | ||
| 141 | } | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
| 145 | /** | ||
| 146 | * port_list_add - add a port to a port list, ensuring no duplicates | ||
| 147 | */ | ||
| 148 | |||
| 149 | static inline void tipc_port_list_add(struct port_list *pl_ptr, u32 port) | ||
| 150 | { | ||
| 151 | struct port_list *item = pl_ptr; | ||
| 152 | int i; | ||
| 153 | int item_sz = PLSIZE; | ||
| 154 | int cnt = pl_ptr->count; | ||
| 155 | |||
| 156 | for (; ; cnt -= item_sz, item = item->next) { | ||
| 157 | if (cnt < PLSIZE) | ||
| 158 | item_sz = cnt; | ||
| 159 | for (i = 0; i < item_sz; i++) | ||
| 160 | if (item->ports[i] == port) | ||
| 161 | return; | ||
| 162 | if (i < PLSIZE) { | ||
| 163 | item->ports[i] = port; | ||
| 164 | pl_ptr->count++; | ||
| 165 | return; | ||
| 166 | } | ||
| 167 | if (!item->next) { | ||
| 168 | item->next = kmalloc(sizeof(*item), GFP_ATOMIC); | ||
| 169 | if (!item->next) { | ||
| 170 | warn("Incomplete multicast delivery, no memory\n"); | ||
| 171 | return; | ||
| 172 | } | ||
| 173 | item->next->next = NULL; | ||
| 174 | } | ||
| 175 | } | ||
| 176 | } | ||
| 177 | |||
| 178 | /** | ||
| 179 | * port_list_free - free dynamically created entries in port_list chain | ||
| 180 | * | ||
| 181 | * Note: First item is on stack, so it doesn't need to be released | ||
| 182 | */ | ||
| 183 | |||
| 184 | static inline void tipc_port_list_free(struct port_list *pl_ptr) | ||
| 185 | { | ||
| 186 | struct port_list *item; | ||
| 187 | struct port_list *next; | ||
| 188 | |||
| 189 | for (item = pl_ptr->next; item; item = next) { | ||
| 190 | next = item->next; | ||
| 191 | kfree(item); | ||
| 192 | } | ||
| 193 | } | ||
| 194 | 89 | ||
| 90 | void tipc_port_list_add(struct port_list *pl_ptr, u32 port); | ||
| 91 | void tipc_port_list_free(struct port_list *pl_ptr); | ||
| 195 | 92 | ||
| 196 | int tipc_bclink_init(void); | 93 | int tipc_bclink_init(void); |
| 197 | void tipc_bclink_stop(void); | 94 | void tipc_bclink_stop(void); |
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 327011fcc407..52ae17b2583e 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
| @@ -45,10 +45,10 @@ | |||
| 45 | 45 | ||
| 46 | #define MAX_ADDR_STR 32 | 46 | #define MAX_ADDR_STR 32 |
| 47 | 47 | ||
| 48 | static struct media *media_list = NULL; | 48 | static struct media media_list[MAX_MEDIA]; |
| 49 | static u32 media_count = 0; | 49 | static u32 media_count = 0; |
| 50 | 50 | ||
| 51 | struct bearer *tipc_bearers = NULL; | 51 | struct bearer tipc_bearers[MAX_BEARERS]; |
| 52 | 52 | ||
| 53 | /** | 53 | /** |
| 54 | * media_name_valid - validate media name | 54 | * media_name_valid - validate media name |
| @@ -108,9 +108,11 @@ int tipc_register_media(u32 media_type, | |||
| 108 | int res = -EINVAL; | 108 | int res = -EINVAL; |
| 109 | 109 | ||
| 110 | write_lock_bh(&tipc_net_lock); | 110 | write_lock_bh(&tipc_net_lock); |
| 111 | if (!media_list) | ||
| 112 | goto exit; | ||
| 113 | 111 | ||
| 112 | if (tipc_mode != TIPC_NET_MODE) { | ||
| 113 | warn("Media <%s> rejected, not in networked mode yet\n", name); | ||
| 114 | goto exit; | ||
| 115 | } | ||
| 114 | if (!media_name_valid(name)) { | 116 | if (!media_name_valid(name)) { |
| 115 | warn("Media <%s> rejected, illegal name\n", name); | 117 | warn("Media <%s> rejected, illegal name\n", name); |
| 116 | goto exit; | 118 | goto exit; |
| @@ -465,6 +467,18 @@ int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr) | |||
| 465 | return res; | 467 | return res; |
| 466 | } | 468 | } |
| 467 | 469 | ||
| 470 | /** | ||
| 471 | * tipc_bearer_congested - determines if bearer is currently congested | ||
| 472 | */ | ||
| 473 | |||
| 474 | int tipc_bearer_congested(struct bearer *b_ptr, struct link *l_ptr) | ||
| 475 | { | ||
| 476 | if (unlikely(b_ptr->publ.blocked)) | ||
| 477 | return 1; | ||
| 478 | if (likely(list_empty(&b_ptr->cong_links))) | ||
| 479 | return 0; | ||
| 480 | return !tipc_bearer_resolve_congestion(b_ptr, l_ptr); | ||
| 481 | } | ||
| 468 | 482 | ||
| 469 | /** | 483 | /** |
| 470 | * tipc_enable_bearer - enable bearer with the given name | 484 | * tipc_enable_bearer - enable bearer with the given name |
| @@ -491,7 +505,7 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority) | |||
| 491 | return -EINVAL; | 505 | return -EINVAL; |
| 492 | } | 506 | } |
| 493 | if (!tipc_addr_domain_valid(bcast_scope) || | 507 | if (!tipc_addr_domain_valid(bcast_scope) || |
| 494 | !in_scope(bcast_scope, tipc_own_addr)) { | 508 | !tipc_in_scope(bcast_scope, tipc_own_addr)) { |
| 495 | warn("Bearer <%s> rejected, illegal broadcast scope\n", name); | 509 | warn("Bearer <%s> rejected, illegal broadcast scope\n", name); |
| 496 | return -EINVAL; | 510 | return -EINVAL; |
| 497 | } | 511 | } |
| @@ -569,7 +583,7 @@ restart: | |||
| 569 | spin_lock_init(&b_ptr->publ.lock); | 583 | spin_lock_init(&b_ptr->publ.lock); |
| 570 | write_unlock_bh(&tipc_net_lock); | 584 | write_unlock_bh(&tipc_net_lock); |
| 571 | info("Enabled bearer <%s>, discovery domain %s, priority %u\n", | 585 | info("Enabled bearer <%s>, discovery domain %s, priority %u\n", |
| 572 | name, addr_string_fill(addr_string, bcast_scope), priority); | 586 | name, tipc_addr_string_fill(addr_string, bcast_scope), priority); |
| 573 | return 0; | 587 | return 0; |
| 574 | failed: | 588 | failed: |
| 575 | write_unlock_bh(&tipc_net_lock); | 589 | write_unlock_bh(&tipc_net_lock); |
| @@ -660,33 +674,10 @@ int tipc_disable_bearer(const char *name) | |||
| 660 | 674 | ||
| 661 | 675 | ||
| 662 | 676 | ||
| 663 | int tipc_bearer_init(void) | ||
| 664 | { | ||
| 665 | int res; | ||
| 666 | |||
| 667 | write_lock_bh(&tipc_net_lock); | ||
| 668 | tipc_bearers = kcalloc(MAX_BEARERS, sizeof(struct bearer), GFP_ATOMIC); | ||
| 669 | media_list = kcalloc(MAX_MEDIA, sizeof(struct media), GFP_ATOMIC); | ||
| 670 | if (tipc_bearers && media_list) { | ||
| 671 | res = 0; | ||
| 672 | } else { | ||
| 673 | kfree(tipc_bearers); | ||
| 674 | kfree(media_list); | ||
| 675 | tipc_bearers = NULL; | ||
| 676 | media_list = NULL; | ||
| 677 | res = -ENOMEM; | ||
| 678 | } | ||
| 679 | write_unlock_bh(&tipc_net_lock); | ||
| 680 | return res; | ||
| 681 | } | ||
| 682 | |||
| 683 | void tipc_bearer_stop(void) | 677 | void tipc_bearer_stop(void) |
| 684 | { | 678 | { |
| 685 | u32 i; | 679 | u32 i; |
| 686 | 680 | ||
| 687 | if (!tipc_bearers) | ||
| 688 | return; | ||
| 689 | |||
| 690 | for (i = 0; i < MAX_BEARERS; i++) { | 681 | for (i = 0; i < MAX_BEARERS; i++) { |
| 691 | if (tipc_bearers[i].active) | 682 | if (tipc_bearers[i].active) |
| 692 | tipc_bearers[i].publ.blocked = 1; | 683 | tipc_bearers[i].publ.blocked = 1; |
| @@ -695,10 +686,6 @@ void tipc_bearer_stop(void) | |||
| 695 | if (tipc_bearers[i].active) | 686 | if (tipc_bearers[i].active) |
| 696 | bearer_disable(tipc_bearers[i].publ.name); | 687 | bearer_disable(tipc_bearers[i].publ.name); |
| 697 | } | 688 | } |
| 698 | kfree(tipc_bearers); | ||
| 699 | kfree(media_list); | ||
| 700 | tipc_bearers = NULL; | ||
| 701 | media_list = NULL; | ||
| 702 | media_count = 0; | 689 | media_count = 0; |
| 703 | } | 690 | } |
| 704 | 691 | ||
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index ca5734892713..a850b389663e 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
| @@ -114,7 +114,7 @@ struct bearer_name { | |||
| 114 | 114 | ||
| 115 | struct link; | 115 | struct link; |
| 116 | 116 | ||
| 117 | extern struct bearer *tipc_bearers; | 117 | extern struct bearer tipc_bearers[]; |
| 118 | 118 | ||
| 119 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a); | 119 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a); |
| 120 | struct sk_buff *tipc_media_get_names(void); | 120 | struct sk_buff *tipc_media_get_names(void); |
| @@ -125,6 +125,7 @@ void tipc_bearer_remove_dest(struct bearer *b_ptr, u32 dest); | |||
| 125 | void tipc_bearer_schedule(struct bearer *b_ptr, struct link *l_ptr); | 125 | void tipc_bearer_schedule(struct bearer *b_ptr, struct link *l_ptr); |
| 126 | struct bearer *tipc_bearer_find_interface(const char *if_name); | 126 | struct bearer *tipc_bearer_find_interface(const char *if_name); |
| 127 | int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr); | 127 | int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr); |
| 128 | int tipc_bearer_congested(struct bearer *b_ptr, struct link *l_ptr); | ||
| 128 | int tipc_bearer_init(void); | 129 | int tipc_bearer_init(void); |
| 129 | void tipc_bearer_stop(void); | 130 | void tipc_bearer_stop(void); |
| 130 | void tipc_bearer_lock_push(struct bearer *b_ptr); | 131 | void tipc_bearer_lock_push(struct bearer *b_ptr); |
| @@ -154,17 +155,4 @@ static inline int tipc_bearer_send(struct bearer *b_ptr, struct sk_buff *buf, | |||
| 154 | return !b_ptr->media->send_msg(buf, &b_ptr->publ, dest); | 155 | return !b_ptr->media->send_msg(buf, &b_ptr->publ, dest); |
| 155 | } | 156 | } |
| 156 | 157 | ||
| 157 | /** | 158 | #endif /* _TIPC_BEARER_H */ |
| 158 | * tipc_bearer_congested - determines if bearer is currently congested | ||
| 159 | */ | ||
| 160 | |||
| 161 | static inline int tipc_bearer_congested(struct bearer *b_ptr, struct link *l_ptr) | ||
| 162 | { | ||
| 163 | if (unlikely(b_ptr->publ.blocked)) | ||
| 164 | return 1; | ||
| 165 | if (likely(list_empty(&b_ptr->cong_links))) | ||
| 166 | return 0; | ||
| 167 | return !tipc_bearer_resolve_congestion(b_ptr, l_ptr); | ||
| 168 | } | ||
| 169 | |||
| 170 | #endif | ||
diff --git a/net/tipc/cluster.c b/net/tipc/cluster.c index a7eac00cd363..e68f705381bc 100644 --- a/net/tipc/cluster.c +++ b/net/tipc/cluster.c | |||
| @@ -238,7 +238,7 @@ static struct sk_buff *tipc_cltr_prepare_routing_msg(u32 data_size, u32 dest) | |||
| 238 | if (buf) { | 238 | if (buf) { |
| 239 | msg = buf_msg(buf); | 239 | msg = buf_msg(buf); |
| 240 | memset((char *)msg, 0, size); | 240 | memset((char *)msg, 0, size); |
| 241 | msg_init(msg, ROUTE_DISTRIBUTOR, 0, INT_H_SIZE, dest); | 241 | tipc_msg_init(msg, ROUTE_DISTRIBUTOR, 0, INT_H_SIZE, dest); |
| 242 | } | 242 | } |
| 243 | return buf; | 243 | return buf; |
| 244 | } | 244 | } |
diff --git a/net/tipc/config.c b/net/tipc/config.c index ca3544d030c7..961d1b097146 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
| @@ -56,9 +56,6 @@ struct subscr_data { | |||
| 56 | struct manager { | 56 | struct manager { |
| 57 | u32 user_ref; | 57 | u32 user_ref; |
| 58 | u32 port_ref; | 58 | u32 port_ref; |
| 59 | u32 subscr_ref; | ||
| 60 | u32 link_subscriptions; | ||
| 61 | struct list_head link_subscribers; | ||
| 62 | }; | 59 | }; |
| 63 | 60 | ||
| 64 | static struct manager mng = { 0}; | 61 | static struct manager mng = { 0}; |
| @@ -70,12 +67,6 @@ static int req_tlv_space; /* request message TLV area size */ | |||
| 70 | static int rep_headroom; /* reply message headroom to use */ | 67 | static int rep_headroom; /* reply message headroom to use */ |
| 71 | 68 | ||
| 72 | 69 | ||
| 73 | void tipc_cfg_link_event(u32 addr, char *name, int up) | ||
| 74 | { | ||
| 75 | /* TIPC DOESN'T HANDLE LINK EVENT SUBSCRIPTIONS AT THE MOMENT */ | ||
| 76 | } | ||
| 77 | |||
| 78 | |||
| 79 | struct sk_buff *tipc_cfg_reply_alloc(int payload_size) | 70 | struct sk_buff *tipc_cfg_reply_alloc(int payload_size) |
| 80 | { | 71 | { |
| 81 | struct sk_buff *buf; | 72 | struct sk_buff *buf; |
| @@ -130,12 +121,24 @@ struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string) | |||
| 130 | } | 121 | } |
| 131 | 122 | ||
| 132 | 123 | ||
| 133 | |||
| 134 | |||
| 135 | #if 0 | 124 | #if 0 |
| 136 | 125 | ||
| 137 | /* Now obsolete code for handling commands not yet implemented the new way */ | 126 | /* Now obsolete code for handling commands not yet implemented the new way */ |
| 138 | 127 | ||
| 128 | /* | ||
| 129 | * Some of this code assumed that the manager structure contains two added | ||
| 130 | * fields: | ||
| 131 | * u32 link_subscriptions; | ||
| 132 | * struct list_head link_subscribers; | ||
| 133 | * which are currently not present. These fields may need to be re-introduced | ||
| 134 | * if and when support for link subscriptions is added. | ||
| 135 | */ | ||
| 136 | |||
| 137 | void tipc_cfg_link_event(u32 addr, char *name, int up) | ||
| 138 | { | ||
| 139 | /* TIPC DOESN'T HANDLE LINK EVENT SUBSCRIPTIONS AT THE MOMENT */ | ||
| 140 | } | ||
| 141 | |||
| 139 | int tipc_cfg_cmd(const struct tipc_cmd_msg * msg, | 142 | int tipc_cfg_cmd(const struct tipc_cmd_msg * msg, |
| 140 | char *data, | 143 | char *data, |
| 141 | u32 sz, | 144 | u32 sz, |
| @@ -243,13 +246,48 @@ static void cfg_cmd_event(struct tipc_cmd_msg *msg, | |||
| 243 | default: | 246 | default: |
| 244 | rv = tipc_cfg_cmd(msg, data, sz, (u32 *)&msg_sect[1].iov_len, orig); | 247 | rv = tipc_cfg_cmd(msg, data, sz, (u32 *)&msg_sect[1].iov_len, orig); |
| 245 | } | 248 | } |
| 246 | exit: | 249 | exit: |
| 247 | rmsg.result_len = htonl(msg_sect[1].iov_len); | 250 | rmsg.result_len = htonl(msg_sect[1].iov_len); |
| 248 | rmsg.retval = htonl(rv); | 251 | rmsg.retval = htonl(rv); |
| 249 | tipc_cfg_respond(msg_sect, 2u, orig); | 252 | tipc_cfg_respond(msg_sect, 2u, orig); |
| 250 | } | 253 | } |
| 251 | #endif | 254 | #endif |
| 252 | 255 | ||
| 256 | #define MAX_STATS_INFO 2000 | ||
| 257 | |||
| 258 | static struct sk_buff *tipc_show_stats(void) | ||
| 259 | { | ||
| 260 | struct sk_buff *buf; | ||
| 261 | struct tlv_desc *rep_tlv; | ||
| 262 | struct print_buf pb; | ||
| 263 | int str_len; | ||
| 264 | u32 value; | ||
| 265 | |||
| 266 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) | ||
| 267 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
| 268 | |||
| 269 | value = ntohl(*(u32 *)TLV_DATA(req_tlv_area)); | ||
| 270 | if (value != 0) | ||
| 271 | return tipc_cfg_reply_error_string("unsupported argument"); | ||
| 272 | |||
| 273 | buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_STATS_INFO)); | ||
| 274 | if (buf == NULL) | ||
| 275 | return NULL; | ||
| 276 | |||
| 277 | rep_tlv = (struct tlv_desc *)buf->data; | ||
| 278 | tipc_printbuf_init(&pb, (char *)TLV_DATA(rep_tlv), MAX_STATS_INFO); | ||
| 279 | |||
| 280 | tipc_printf(&pb, "TIPC version " TIPC_MOD_VER "\n"); | ||
| 281 | |||
| 282 | /* Use additional tipc_printf()'s to return more info ... */ | ||
| 283 | |||
| 284 | str_len = tipc_printbuf_validate(&pb); | ||
| 285 | skb_put(buf, TLV_SPACE(str_len)); | ||
| 286 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); | ||
| 287 | |||
| 288 | return buf; | ||
| 289 | } | ||
| 290 | |||
| 253 | static struct sk_buff *cfg_enable_bearer(void) | 291 | static struct sk_buff *cfg_enable_bearer(void) |
| 254 | { | 292 | { |
| 255 | struct tipc_bearer_config *args; | 293 | struct tipc_bearer_config *args; |
| @@ -533,6 +571,9 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
| 533 | case TIPC_CMD_DUMP_LOG: | 571 | case TIPC_CMD_DUMP_LOG: |
| 534 | rep_tlv_buf = tipc_log_dump(); | 572 | rep_tlv_buf = tipc_log_dump(); |
| 535 | break; | 573 | break; |
| 574 | case TIPC_CMD_SHOW_STATS: | ||
| 575 | rep_tlv_buf = tipc_show_stats(); | ||
| 576 | break; | ||
| 536 | case TIPC_CMD_SET_LINK_TOL: | 577 | case TIPC_CMD_SET_LINK_TOL: |
| 537 | case TIPC_CMD_SET_LINK_PRI: | 578 | case TIPC_CMD_SET_LINK_PRI: |
| 538 | case TIPC_CMD_SET_LINK_WINDOW: | 579 | case TIPC_CMD_SET_LINK_WINDOW: |
| @@ -667,9 +708,6 @@ int tipc_cfg_init(void) | |||
| 667 | struct tipc_name_seq seq; | 708 | struct tipc_name_seq seq; |
| 668 | int res; | 709 | int res; |
| 669 | 710 | ||
| 670 | memset(&mng, 0, sizeof(mng)); | ||
| 671 | INIT_LIST_HEAD(&mng.link_subscribers); | ||
| 672 | |||
| 673 | res = tipc_attach(&mng.user_ref, NULL, NULL); | 711 | res = tipc_attach(&mng.user_ref, NULL, NULL); |
| 674 | if (res) | 712 | if (res) |
| 675 | goto failed; | 713 | goto failed; |
diff --git a/net/tipc/core.c b/net/tipc/core.c index 3256bd7d398f..696468117985 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
| @@ -49,8 +49,6 @@ | |||
| 49 | #include "config.h" | 49 | #include "config.h" |
| 50 | 50 | ||
| 51 | 51 | ||
| 52 | #define TIPC_MOD_VER "1.6.4" | ||
| 53 | |||
| 54 | #ifndef CONFIG_TIPC_ZONES | 52 | #ifndef CONFIG_TIPC_ZONES |
| 55 | #define CONFIG_TIPC_ZONES 3 | 53 | #define CONFIG_TIPC_ZONES 3 |
| 56 | #endif | 54 | #endif |
| @@ -104,6 +102,30 @@ int tipc_get_mode(void) | |||
| 104 | } | 102 | } |
| 105 | 103 | ||
| 106 | /** | 104 | /** |
| 105 | * buf_acquire - creates a TIPC message buffer | ||
| 106 | * @size: message size (including TIPC header) | ||
| 107 | * | ||
| 108 | * Returns a new buffer with data pointers set to the specified size. | ||
| 109 | * | ||
| 110 | * NOTE: Headroom is reserved to allow prepending of a data link header. | ||
| 111 | * There may also be unrequested tailroom present at the buffer's end. | ||
| 112 | */ | ||
| 113 | |||
| 114 | struct sk_buff *buf_acquire(u32 size) | ||
| 115 | { | ||
| 116 | struct sk_buff *skb; | ||
| 117 | unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u; | ||
| 118 | |||
| 119 | skb = alloc_skb_fclone(buf_size, GFP_ATOMIC); | ||
| 120 | if (skb) { | ||
| 121 | skb_reserve(skb, BUF_HEADROOM); | ||
| 122 | skb_put(skb, size); | ||
| 123 | skb->next = NULL; | ||
| 124 | } | ||
| 125 | return skb; | ||
| 126 | } | ||
| 127 | |||
| 128 | /** | ||
| 107 | * tipc_core_stop_net - shut down TIPC networking sub-systems | 129 | * tipc_core_stop_net - shut down TIPC networking sub-systems |
| 108 | */ | 130 | */ |
| 109 | 131 | ||
| @@ -189,11 +211,11 @@ static int __init tipc_init(void) | |||
| 189 | tipc_remote_management = 1; | 211 | tipc_remote_management = 1; |
| 190 | tipc_max_publications = 10000; | 212 | tipc_max_publications = 10000; |
| 191 | tipc_max_subscriptions = 2000; | 213 | tipc_max_subscriptions = 2000; |
| 192 | tipc_max_ports = delimit(CONFIG_TIPC_PORTS, 127, 65536); | 214 | tipc_max_ports = CONFIG_TIPC_PORTS; |
| 193 | tipc_max_zones = delimit(CONFIG_TIPC_ZONES, 1, 255); | 215 | tipc_max_zones = CONFIG_TIPC_ZONES; |
| 194 | tipc_max_clusters = delimit(CONFIG_TIPC_CLUSTERS, 1, 1); | 216 | tipc_max_clusters = CONFIG_TIPC_CLUSTERS; |
| 195 | tipc_max_nodes = delimit(CONFIG_TIPC_NODES, 8, 2047); | 217 | tipc_max_nodes = CONFIG_TIPC_NODES; |
| 196 | tipc_max_slaves = delimit(CONFIG_TIPC_SLAVE_NODES, 0, 2047); | 218 | tipc_max_slaves = CONFIG_TIPC_SLAVE_NODES; |
| 197 | tipc_net_id = 4711; | 219 | tipc_net_id = 4711; |
| 198 | 220 | ||
| 199 | if ((res = tipc_core_start())) | 221 | if ((res = tipc_core_start())) |
diff --git a/net/tipc/core.h b/net/tipc/core.h index a881f92a8537..188799017abd 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h | |||
| @@ -56,8 +56,12 @@ | |||
| 56 | #include <linux/netdevice.h> | 56 | #include <linux/netdevice.h> |
| 57 | #include <linux/in.h> | 57 | #include <linux/in.h> |
| 58 | #include <linux/list.h> | 58 | #include <linux/list.h> |
| 59 | #include <linux/slab.h> | ||
| 59 | #include <linux/vmalloc.h> | 60 | #include <linux/vmalloc.h> |
| 60 | 61 | ||
| 62 | |||
| 63 | #define TIPC_MOD_VER "2.0.0" | ||
| 64 | |||
| 61 | /* | 65 | /* |
| 62 | * TIPC sanity test macros | 66 | * TIPC sanity test macros |
| 63 | */ | 67 | */ |
| @@ -324,29 +328,7 @@ static inline struct tipc_msg *buf_msg(struct sk_buff *skb) | |||
| 324 | return (struct tipc_msg *)skb->data; | 328 | return (struct tipc_msg *)skb->data; |
| 325 | } | 329 | } |
| 326 | 330 | ||
| 327 | /** | 331 | extern struct sk_buff *buf_acquire(u32 size); |
| 328 | * buf_acquire - creates a TIPC message buffer | ||
| 329 | * @size: message size (including TIPC header) | ||
| 330 | * | ||
| 331 | * Returns a new buffer with data pointers set to the specified size. | ||
| 332 | * | ||
| 333 | * NOTE: Headroom is reserved to allow prepending of a data link header. | ||
| 334 | * There may also be unrequested tailroom present at the buffer's end. | ||
| 335 | */ | ||
| 336 | |||
| 337 | static inline struct sk_buff *buf_acquire(u32 size) | ||
| 338 | { | ||
| 339 | struct sk_buff *skb; | ||
| 340 | unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u; | ||
| 341 | |||
| 342 | skb = alloc_skb_fclone(buf_size, GFP_ATOMIC); | ||
| 343 | if (skb) { | ||
| 344 | skb_reserve(skb, BUF_HEADROOM); | ||
| 345 | skb_put(skb, size); | ||
| 346 | skb->next = NULL; | ||
| 347 | } | ||
| 348 | return skb; | ||
| 349 | } | ||
| 350 | 332 | ||
| 351 | /** | 333 | /** |
| 352 | * buf_discard - frees a TIPC message buffer | 334 | * buf_discard - frees a TIPC message buffer |
diff --git a/net/tipc/discover.c b/net/tipc/discover.c index 74b7d1e28aec..fc1fcf5e6b53 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c | |||
| @@ -120,7 +120,7 @@ static struct sk_buff *tipc_disc_init_msg(u32 type, | |||
| 120 | 120 | ||
| 121 | if (buf) { | 121 | if (buf) { |
| 122 | msg = buf_msg(buf); | 122 | msg = buf_msg(buf); |
| 123 | msg_init(msg, LINK_CONFIG, type, DSC_H_SIZE, dest_domain); | 123 | tipc_msg_init(msg, LINK_CONFIG, type, DSC_H_SIZE, dest_domain); |
| 124 | msg_set_non_seq(msg, 1); | 124 | msg_set_non_seq(msg, 1); |
| 125 | msg_set_req_links(msg, req_links); | 125 | msg_set_req_links(msg, req_links); |
| 126 | msg_set_dest_domain(msg, dest_domain); | 126 | msg_set_dest_domain(msg, dest_domain); |
| @@ -144,7 +144,7 @@ static void disc_dupl_alert(struct bearer *b_ptr, u32 node_addr, | |||
| 144 | char media_addr_str[64]; | 144 | char media_addr_str[64]; |
| 145 | struct print_buf pb; | 145 | struct print_buf pb; |
| 146 | 146 | ||
| 147 | addr_string_fill(node_addr_str, node_addr); | 147 | tipc_addr_string_fill(node_addr_str, node_addr); |
| 148 | tipc_printbuf_init(&pb, media_addr_str, sizeof(media_addr_str)); | 148 | tipc_printbuf_init(&pb, media_addr_str, sizeof(media_addr_str)); |
| 149 | tipc_media_addr_printf(&pb, media_addr); | 149 | tipc_media_addr_printf(&pb, media_addr); |
| 150 | tipc_printbuf_validate(&pb); | 150 | tipc_printbuf_validate(&pb); |
| @@ -183,7 +183,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr) | |||
| 183 | disc_dupl_alert(b_ptr, tipc_own_addr, &media_addr); | 183 | disc_dupl_alert(b_ptr, tipc_own_addr, &media_addr); |
| 184 | return; | 184 | return; |
| 185 | } | 185 | } |
| 186 | if (!in_scope(dest, tipc_own_addr)) | 186 | if (!tipc_in_scope(dest, tipc_own_addr)) |
| 187 | return; | 187 | return; |
| 188 | if (is_slave(tipc_own_addr) && is_slave(orig)) | 188 | if (is_slave(tipc_own_addr) && is_slave(orig)) |
| 189 | return; | 189 | return; |
| @@ -224,7 +224,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr) | |||
| 224 | memcpy(addr, &media_addr, sizeof(*addr)); | 224 | memcpy(addr, &media_addr, sizeof(*addr)); |
| 225 | tipc_link_reset(link); | 225 | tipc_link_reset(link); |
| 226 | } | 226 | } |
| 227 | link_fully_up = (link->state == WORKING_WORKING); | 227 | link_fully_up = link_working_working(link); |
| 228 | spin_unlock_bh(&n_ptr->lock); | 228 | spin_unlock_bh(&n_ptr->lock); |
| 229 | if ((type == DSC_RESP_MSG) || link_fully_up) | 229 | if ((type == DSC_RESP_MSG) || link_fully_up) |
| 230 | return; | 230 | return; |
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index 524ba5696d4d..6230d16020c4 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #include <net/tipc/tipc_bearer.h> | 38 | #include <net/tipc/tipc_bearer.h> |
| 39 | #include <net/tipc/tipc_msg.h> | 39 | #include <net/tipc/tipc_msg.h> |
| 40 | #include <linux/netdevice.h> | 40 | #include <linux/netdevice.h> |
| 41 | #include <linux/slab.h> | ||
| 41 | #include <net/net_namespace.h> | 42 | #include <net/net_namespace.h> |
| 42 | 43 | ||
| 43 | #define MAX_ETH_BEARERS 2 | 44 | #define MAX_ETH_BEARERS 2 |
diff --git a/net/tipc/link.c b/net/tipc/link.c index 6f50f6423f63..a3616b99529b 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
| @@ -202,41 +202,6 @@ static unsigned int align(unsigned int i) | |||
| 202 | return (i + 3) & ~3u; | 202 | return (i + 3) & ~3u; |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | static int link_working_working(struct link *l_ptr) | ||
| 206 | { | ||
| 207 | return (l_ptr->state == WORKING_WORKING); | ||
| 208 | } | ||
| 209 | |||
| 210 | static int link_working_unknown(struct link *l_ptr) | ||
| 211 | { | ||
| 212 | return (l_ptr->state == WORKING_UNKNOWN); | ||
| 213 | } | ||
| 214 | |||
| 215 | static int link_reset_unknown(struct link *l_ptr) | ||
| 216 | { | ||
| 217 | return (l_ptr->state == RESET_UNKNOWN); | ||
| 218 | } | ||
| 219 | |||
| 220 | static int link_reset_reset(struct link *l_ptr) | ||
| 221 | { | ||
| 222 | return (l_ptr->state == RESET_RESET); | ||
| 223 | } | ||
| 224 | |||
| 225 | static int link_blocked(struct link *l_ptr) | ||
| 226 | { | ||
| 227 | return (l_ptr->exp_msg_count || l_ptr->blocked); | ||
| 228 | } | ||
| 229 | |||
| 230 | static int link_congested(struct link *l_ptr) | ||
| 231 | { | ||
| 232 | return (l_ptr->out_queue_size >= l_ptr->queue_limit[0]); | ||
| 233 | } | ||
| 234 | |||
| 235 | static u32 link_max_pkt(struct link *l_ptr) | ||
| 236 | { | ||
| 237 | return l_ptr->max_pkt; | ||
| 238 | } | ||
| 239 | |||
| 240 | static void link_init_max_pkt(struct link *l_ptr) | 205 | static void link_init_max_pkt(struct link *l_ptr) |
| 241 | { | 206 | { |
| 242 | u32 max_pkt; | 207 | u32 max_pkt; |
| @@ -468,7 +433,7 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer, | |||
| 468 | 433 | ||
| 469 | l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; | 434 | l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; |
| 470 | msg = l_ptr->pmsg; | 435 | msg = l_ptr->pmsg; |
| 471 | msg_init(msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE, l_ptr->addr); | 436 | tipc_msg_init(msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE, l_ptr->addr); |
| 472 | msg_set_size(msg, sizeof(l_ptr->proto_msg)); | 437 | msg_set_size(msg, sizeof(l_ptr->proto_msg)); |
| 473 | msg_set_session(msg, (tipc_random & 0xffff)); | 438 | msg_set_session(msg, (tipc_random & 0xffff)); |
| 474 | msg_set_bearer_id(msg, b_ptr->identity); | 439 | msg_set_bearer_id(msg, b_ptr->identity); |
| @@ -561,9 +526,8 @@ static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz) | |||
| 561 | goto exit; | 526 | goto exit; |
| 562 | if (!list_empty(&p_ptr->wait_list)) | 527 | if (!list_empty(&p_ptr->wait_list)) |
| 563 | goto exit; | 528 | goto exit; |
| 564 | p_ptr->congested_link = l_ptr; | ||
| 565 | p_ptr->publ.congested = 1; | 529 | p_ptr->publ.congested = 1; |
| 566 | p_ptr->waiting_pkts = 1 + ((sz - 1) / link_max_pkt(l_ptr)); | 530 | p_ptr->waiting_pkts = 1 + ((sz - 1) / l_ptr->max_pkt); |
| 567 | list_add_tail(&p_ptr->wait_list, &l_ptr->waiting_ports); | 531 | list_add_tail(&p_ptr->wait_list, &l_ptr->waiting_ports); |
| 568 | l_ptr->stats.link_congs++; | 532 | l_ptr->stats.link_congs++; |
| 569 | exit: | 533 | exit: |
| @@ -592,7 +556,6 @@ void tipc_link_wakeup_ports(struct link *l_ptr, int all) | |||
| 592 | if (win <= 0) | 556 | if (win <= 0) |
| 593 | break; | 557 | break; |
| 594 | list_del_init(&p_ptr->wait_list); | 558 | list_del_init(&p_ptr->wait_list); |
| 595 | p_ptr->congested_link = NULL; | ||
| 596 | spin_lock_bh(p_ptr->publ.lock); | 559 | spin_lock_bh(p_ptr->publ.lock); |
| 597 | p_ptr->publ.congested = 0; | 560 | p_ptr->publ.congested = 0; |
| 598 | p_ptr->wakeup(&p_ptr->publ); | 561 | p_ptr->wakeup(&p_ptr->publ); |
| @@ -877,7 +840,7 @@ static void link_state_event(struct link *l_ptr, unsigned event) | |||
| 877 | case TIMEOUT_EVT: | 840 | case TIMEOUT_EVT: |
| 878 | dbg_link("TIM "); | 841 | dbg_link("TIM "); |
| 879 | if (l_ptr->next_in_no != l_ptr->checkpoint) { | 842 | if (l_ptr->next_in_no != l_ptr->checkpoint) { |
| 880 | dbg_link("-> WW \n"); | 843 | dbg_link("-> WW\n"); |
| 881 | l_ptr->state = WORKING_WORKING; | 844 | l_ptr->state = WORKING_WORKING; |
| 882 | l_ptr->fsm_msg_cnt = 0; | 845 | l_ptr->fsm_msg_cnt = 0; |
| 883 | l_ptr->checkpoint = l_ptr->next_in_no; | 846 | l_ptr->checkpoint = l_ptr->next_in_no; |
| @@ -934,7 +897,7 @@ static void link_state_event(struct link *l_ptr, unsigned event) | |||
| 934 | link_set_timer(l_ptr, cont_intv); | 897 | link_set_timer(l_ptr, cont_intv); |
| 935 | break; | 898 | break; |
| 936 | case RESET_MSG: | 899 | case RESET_MSG: |
| 937 | dbg_link("RES \n"); | 900 | dbg_link("RES\n"); |
| 938 | dbg_link(" -> RR\n"); | 901 | dbg_link(" -> RR\n"); |
| 939 | l_ptr->state = RESET_RESET; | 902 | l_ptr->state = RESET_RESET; |
| 940 | l_ptr->fsm_msg_cnt = 0; | 903 | l_ptr->fsm_msg_cnt = 0; |
| @@ -947,7 +910,7 @@ static void link_state_event(struct link *l_ptr, unsigned event) | |||
| 947 | l_ptr->started = 1; | 910 | l_ptr->started = 1; |
| 948 | /* fall through */ | 911 | /* fall through */ |
| 949 | case TIMEOUT_EVT: | 912 | case TIMEOUT_EVT: |
| 950 | dbg_link("TIM \n"); | 913 | dbg_link("TIM\n"); |
| 951 | tipc_link_send_proto_msg(l_ptr, RESET_MSG, 0, 0, 0, 0, 0); | 914 | tipc_link_send_proto_msg(l_ptr, RESET_MSG, 0, 0, 0, 0, 0); |
| 952 | l_ptr->fsm_msg_cnt++; | 915 | l_ptr->fsm_msg_cnt++; |
| 953 | link_set_timer(l_ptr, cont_intv); | 916 | link_set_timer(l_ptr, cont_intv); |
| @@ -1017,7 +980,7 @@ static int link_bundle_buf(struct link *l_ptr, | |||
| 1017 | return 0; | 980 | return 0; |
| 1018 | if (skb_tailroom(bundler) < (pad + size)) | 981 | if (skb_tailroom(bundler) < (pad + size)) |
| 1019 | return 0; | 982 | return 0; |
| 1020 | if (link_max_pkt(l_ptr) < (to_pos + size)) | 983 | if (l_ptr->max_pkt < (to_pos + size)) |
| 1021 | return 0; | 984 | return 0; |
| 1022 | 985 | ||
| 1023 | skb_put(bundler, pad + size); | 986 | skb_put(bundler, pad + size); |
| @@ -1062,9 +1025,9 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) | |||
| 1062 | u32 size = msg_size(msg); | 1025 | u32 size = msg_size(msg); |
| 1063 | u32 dsz = msg_data_sz(msg); | 1026 | u32 dsz = msg_data_sz(msg); |
| 1064 | u32 queue_size = l_ptr->out_queue_size; | 1027 | u32 queue_size = l_ptr->out_queue_size; |
| 1065 | u32 imp = msg_tot_importance(msg); | 1028 | u32 imp = tipc_msg_tot_importance(msg); |
| 1066 | u32 queue_limit = l_ptr->queue_limit[imp]; | 1029 | u32 queue_limit = l_ptr->queue_limit[imp]; |
| 1067 | u32 max_packet = link_max_pkt(l_ptr); | 1030 | u32 max_packet = l_ptr->max_pkt; |
| 1068 | 1031 | ||
| 1069 | msg_set_prevnode(msg, tipc_own_addr); /* If routed message */ | 1032 | msg_set_prevnode(msg, tipc_own_addr); /* If routed message */ |
| 1070 | 1033 | ||
| @@ -1127,7 +1090,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) | |||
| 1127 | struct tipc_msg bundler_hdr; | 1090 | struct tipc_msg bundler_hdr; |
| 1128 | 1091 | ||
| 1129 | if (bundler) { | 1092 | if (bundler) { |
| 1130 | msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG, | 1093 | tipc_msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG, |
| 1131 | INT_H_SIZE, l_ptr->addr); | 1094 | INT_H_SIZE, l_ptr->addr); |
| 1132 | skb_copy_to_linear_data(bundler, &bundler_hdr, | 1095 | skb_copy_to_linear_data(bundler, &bundler_hdr, |
| 1133 | INT_H_SIZE); | 1096 | INT_H_SIZE); |
| @@ -1195,7 +1158,7 @@ static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf, | |||
| 1195 | int res = msg_data_sz(msg); | 1158 | int res = msg_data_sz(msg); |
| 1196 | 1159 | ||
| 1197 | if (likely(!link_congested(l_ptr))) { | 1160 | if (likely(!link_congested(l_ptr))) { |
| 1198 | if (likely(msg_size(msg) <= link_max_pkt(l_ptr))) { | 1161 | if (likely(msg_size(msg) <= l_ptr->max_pkt)) { |
| 1199 | if (likely(list_empty(&l_ptr->b_ptr->cong_links))) { | 1162 | if (likely(list_empty(&l_ptr->b_ptr->cong_links))) { |
| 1200 | link_add_to_outqueue(l_ptr, buf, msg); | 1163 | link_add_to_outqueue(l_ptr, buf, msg); |
| 1201 | if (likely(tipc_bearer_send(l_ptr->b_ptr, buf, | 1164 | if (likely(tipc_bearer_send(l_ptr->b_ptr, buf, |
| @@ -1212,7 +1175,7 @@ static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf, | |||
| 1212 | } | 1175 | } |
| 1213 | } | 1176 | } |
| 1214 | else | 1177 | else |
| 1215 | *used_max_pkt = link_max_pkt(l_ptr); | 1178 | *used_max_pkt = l_ptr->max_pkt; |
| 1216 | } | 1179 | } |
| 1217 | return tipc_link_send_buf(l_ptr, buf); /* All other cases */ | 1180 | return tipc_link_send_buf(l_ptr, buf); /* All other cases */ |
| 1218 | } | 1181 | } |
| @@ -1280,7 +1243,7 @@ again: | |||
| 1280 | * (Must not hold any locks while building message.) | 1243 | * (Must not hold any locks while building message.) |
| 1281 | */ | 1244 | */ |
| 1282 | 1245 | ||
| 1283 | res = msg_build(hdr, msg_sect, num_sect, sender->publ.max_pkt, | 1246 | res = tipc_msg_build(hdr, msg_sect, num_sect, sender->publ.max_pkt, |
| 1284 | !sender->user_port, &buf); | 1247 | !sender->user_port, &buf); |
| 1285 | 1248 | ||
| 1286 | read_lock_bh(&tipc_net_lock); | 1249 | read_lock_bh(&tipc_net_lock); |
| @@ -1319,7 +1282,7 @@ exit: | |||
| 1319 | * then re-try fast path or fragment the message | 1282 | * then re-try fast path or fragment the message |
| 1320 | */ | 1283 | */ |
| 1321 | 1284 | ||
| 1322 | sender->publ.max_pkt = link_max_pkt(l_ptr); | 1285 | sender->publ.max_pkt = l_ptr->max_pkt; |
| 1323 | tipc_node_unlock(node); | 1286 | tipc_node_unlock(node); |
| 1324 | read_unlock_bh(&tipc_net_lock); | 1287 | read_unlock_bh(&tipc_net_lock); |
| 1325 | 1288 | ||
| @@ -1391,7 +1354,7 @@ again: | |||
| 1391 | /* Prepare reusable fragment header: */ | 1354 | /* Prepare reusable fragment header: */ |
| 1392 | 1355 | ||
| 1393 | msg_dbg(hdr, ">FRAGMENTING>"); | 1356 | msg_dbg(hdr, ">FRAGMENTING>"); |
| 1394 | msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, | 1357 | tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, |
| 1395 | INT_H_SIZE, msg_destnode(hdr)); | 1358 | INT_H_SIZE, msg_destnode(hdr)); |
| 1396 | msg_set_link_selector(&fragm_hdr, sender->publ.ref); | 1359 | msg_set_link_selector(&fragm_hdr, sender->publ.ref); |
| 1397 | msg_set_size(&fragm_hdr, max_pkt); | 1360 | msg_set_size(&fragm_hdr, max_pkt); |
| @@ -1482,8 +1445,8 @@ error: | |||
| 1482 | tipc_node_unlock(node); | 1445 | tipc_node_unlock(node); |
| 1483 | goto reject; | 1446 | goto reject; |
| 1484 | } | 1447 | } |
| 1485 | if (link_max_pkt(l_ptr) < max_pkt) { | 1448 | if (l_ptr->max_pkt < max_pkt) { |
| 1486 | sender->publ.max_pkt = link_max_pkt(l_ptr); | 1449 | sender->publ.max_pkt = l_ptr->max_pkt; |
| 1487 | tipc_node_unlock(node); | 1450 | tipc_node_unlock(node); |
| 1488 | for (; buf_chain; buf_chain = buf) { | 1451 | for (; buf_chain; buf_chain = buf) { |
| 1489 | buf = buf_chain->next; | 1452 | buf = buf_chain->next; |
| @@ -1553,7 +1516,7 @@ u32 tipc_link_push_packet(struct link *l_ptr) | |||
| 1553 | 1516 | ||
| 1554 | /* Continue retransmission now, if there is anything: */ | 1517 | /* Continue retransmission now, if there is anything: */ |
| 1555 | 1518 | ||
| 1556 | if (r_q_size && buf && !skb_cloned(buf)) { | 1519 | if (r_q_size && buf) { |
| 1557 | msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1)); | 1520 | msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1)); |
| 1558 | msg_set_bcast_ack(buf_msg(buf), l_ptr->owner->bclink.last_in); | 1521 | msg_set_bcast_ack(buf_msg(buf), l_ptr->owner->bclink.last_in); |
| 1559 | if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { | 1522 | if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { |
| @@ -1650,7 +1613,7 @@ static void link_reset_all(unsigned long addr) | |||
| 1650 | tipc_node_lock(n_ptr); | 1613 | tipc_node_lock(n_ptr); |
| 1651 | 1614 | ||
| 1652 | warn("Resetting all links to %s\n", | 1615 | warn("Resetting all links to %s\n", |
| 1653 | addr_string_fill(addr_string, n_ptr->addr)); | 1616 | tipc_addr_string_fill(addr_string, n_ptr->addr)); |
| 1654 | 1617 | ||
| 1655 | for (i = 0; i < MAX_BEARERS; i++) { | 1618 | for (i = 0; i < MAX_BEARERS; i++) { |
| 1656 | if (n_ptr->links[i]) { | 1619 | if (n_ptr->links[i]) { |
| @@ -1692,7 +1655,7 @@ static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf) | |||
| 1692 | n_ptr = l_ptr->owner->next; | 1655 | n_ptr = l_ptr->owner->next; |
| 1693 | tipc_node_lock(n_ptr); | 1656 | tipc_node_lock(n_ptr); |
| 1694 | 1657 | ||
| 1695 | addr_string_fill(addr_string, n_ptr->addr); | 1658 | tipc_addr_string_fill(addr_string, n_ptr->addr); |
| 1696 | tipc_printf(TIPC_OUTPUT, "Multicast link info for %s\n", addr_string); | 1659 | tipc_printf(TIPC_OUTPUT, "Multicast link info for %s\n", addr_string); |
| 1697 | tipc_printf(TIPC_OUTPUT, "Supported: %d, ", n_ptr->bclink.supported); | 1660 | tipc_printf(TIPC_OUTPUT, "Supported: %d, ", n_ptr->bclink.supported); |
| 1698 | tipc_printf(TIPC_OUTPUT, "Acked: %u\n", n_ptr->bclink.acked); | 1661 | tipc_printf(TIPC_OUTPUT, "Acked: %u\n", n_ptr->bclink.acked); |
| @@ -1722,15 +1685,16 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf, | |||
| 1722 | dbg("Retransmitting %u in link %x\n", retransmits, l_ptr); | 1685 | dbg("Retransmitting %u in link %x\n", retransmits, l_ptr); |
| 1723 | 1686 | ||
| 1724 | if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) { | 1687 | if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) { |
| 1725 | if (!skb_cloned(buf)) { | 1688 | if (l_ptr->retransm_queue_size == 0) { |
| 1726 | msg_dbg(msg, ">NO_RETR->BCONG>"); | 1689 | msg_dbg(msg, ">NO_RETR->BCONG>"); |
| 1727 | dbg_print_link(l_ptr, " "); | 1690 | dbg_print_link(l_ptr, " "); |
| 1728 | l_ptr->retransm_queue_head = msg_seqno(msg); | 1691 | l_ptr->retransm_queue_head = msg_seqno(msg); |
| 1729 | l_ptr->retransm_queue_size = retransmits; | 1692 | l_ptr->retransm_queue_size = retransmits; |
| 1730 | return; | ||
| 1731 | } else { | 1693 | } else { |
| 1732 | /* Don't retransmit if driver already has the buffer */ | 1694 | err("Unexpected retransmit on link %s (qsize=%d)\n", |
| 1695 | l_ptr->name, l_ptr->retransm_queue_size); | ||
| 1733 | } | 1696 | } |
| 1697 | return; | ||
| 1734 | } else { | 1698 | } else { |
| 1735 | /* Detect repeated retransmit failures on uncongested bearer */ | 1699 | /* Detect repeated retransmit failures on uncongested bearer */ |
| 1736 | 1700 | ||
| @@ -1745,7 +1709,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf, | |||
| 1745 | } | 1709 | } |
| 1746 | } | 1710 | } |
| 1747 | 1711 | ||
| 1748 | while (retransmits && (buf != l_ptr->next_out) && buf && !skb_cloned(buf)) { | 1712 | while (retransmits && (buf != l_ptr->next_out) && buf) { |
| 1749 | msg = buf_msg(buf); | 1713 | msg = buf_msg(buf); |
| 1750 | msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); | 1714 | msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); |
| 1751 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); | 1715 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); |
| @@ -1882,6 +1846,15 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) | |||
| 1882 | (msg_destnode(msg) != tipc_own_addr))) | 1846 | (msg_destnode(msg) != tipc_own_addr))) |
| 1883 | goto cont; | 1847 | goto cont; |
| 1884 | 1848 | ||
| 1849 | /* Discard non-routeable messages destined for another node */ | ||
| 1850 | |||
| 1851 | if (unlikely(!msg_isdata(msg) && | ||
| 1852 | (msg_destnode(msg) != tipc_own_addr))) { | ||
| 1853 | if ((msg_user(msg) != CONN_MANAGER) && | ||
| 1854 | (msg_user(msg) != MSG_FRAGMENTER)) | ||
| 1855 | goto cont; | ||
| 1856 | } | ||
| 1857 | |||
| 1885 | /* Locate unicast link endpoint that should handle message */ | 1858 | /* Locate unicast link endpoint that should handle message */ |
| 1886 | 1859 | ||
| 1887 | n_ptr = tipc_node_find(msg_prevnode(msg)); | 1860 | n_ptr = tipc_node_find(msg_prevnode(msg)); |
| @@ -2425,7 +2398,7 @@ void tipc_link_changeover(struct link *l_ptr) | |||
| 2425 | return; | 2398 | return; |
| 2426 | } | 2399 | } |
| 2427 | 2400 | ||
| 2428 | msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, | 2401 | tipc_msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, |
| 2429 | ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr); | 2402 | ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr); |
| 2430 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); | 2403 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); |
| 2431 | msg_set_msgcnt(&tunnel_hdr, msgcount); | 2404 | msg_set_msgcnt(&tunnel_hdr, msgcount); |
| @@ -2480,7 +2453,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel) | |||
| 2480 | struct sk_buff *iter; | 2453 | struct sk_buff *iter; |
| 2481 | struct tipc_msg tunnel_hdr; | 2454 | struct tipc_msg tunnel_hdr; |
| 2482 | 2455 | ||
| 2483 | msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, | 2456 | tipc_msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, |
| 2484 | DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr); | 2457 | DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr); |
| 2485 | msg_set_msgcnt(&tunnel_hdr, l_ptr->out_queue_size); | 2458 | msg_set_msgcnt(&tunnel_hdr, l_ptr->out_queue_size); |
| 2486 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); | 2459 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); |
| @@ -2671,7 +2644,7 @@ int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf) | |||
| 2671 | u32 dsz = msg_data_sz(inmsg); | 2644 | u32 dsz = msg_data_sz(inmsg); |
| 2672 | unchar *crs = buf->data; | 2645 | unchar *crs = buf->data; |
| 2673 | u32 rest = insize; | 2646 | u32 rest = insize; |
| 2674 | u32 pack_sz = link_max_pkt(l_ptr); | 2647 | u32 pack_sz = l_ptr->max_pkt; |
| 2675 | u32 fragm_sz = pack_sz - INT_H_SIZE; | 2648 | u32 fragm_sz = pack_sz - INT_H_SIZE; |
| 2676 | u32 fragm_no = 1; | 2649 | u32 fragm_no = 1; |
| 2677 | u32 destaddr; | 2650 | u32 destaddr; |
| @@ -2686,7 +2659,7 @@ int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf) | |||
| 2686 | 2659 | ||
| 2687 | /* Prepare reusable fragment header: */ | 2660 | /* Prepare reusable fragment header: */ |
| 2688 | 2661 | ||
| 2689 | msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, | 2662 | tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, |
| 2690 | INT_H_SIZE, destaddr); | 2663 | INT_H_SIZE, destaddr); |
| 2691 | msg_set_link_selector(&fragm_hdr, msg_link_selector(inmsg)); | 2664 | msg_set_link_selector(&fragm_hdr, msg_link_selector(inmsg)); |
| 2692 | msg_set_long_msgno(&fragm_hdr, mod(l_ptr->long_msg_seq_no++)); | 2665 | msg_set_long_msgno(&fragm_hdr, mod(l_ptr->long_msg_seq_no++)); |
| @@ -3117,7 +3090,7 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) | |||
| 3117 | tipc_printf(&pb, "Link <%s>\n" | 3090 | tipc_printf(&pb, "Link <%s>\n" |
| 3118 | " %s MTU:%u Priority:%u Tolerance:%u ms" | 3091 | " %s MTU:%u Priority:%u Tolerance:%u ms" |
| 3119 | " Window:%u packets\n", | 3092 | " Window:%u packets\n", |
| 3120 | l_ptr->name, status, link_max_pkt(l_ptr), | 3093 | l_ptr->name, status, l_ptr->max_pkt, |
| 3121 | l_ptr->priority, l_ptr->tolerance, l_ptr->queue_limit[0]); | 3094 | l_ptr->priority, l_ptr->tolerance, l_ptr->queue_limit[0]); |
| 3122 | tipc_printf(&pb, " RX packets:%u fragments:%u/%u bundles:%u/%u\n", | 3095 | tipc_printf(&pb, " RX packets:%u fragments:%u/%u bundles:%u/%u\n", |
| 3123 | l_ptr->next_in_no - l_ptr->stats.recv_info, | 3096 | l_ptr->next_in_no - l_ptr->stats.recv_info, |
| @@ -3262,7 +3235,7 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector) | |||
| 3262 | tipc_node_lock(n_ptr); | 3235 | tipc_node_lock(n_ptr); |
| 3263 | l_ptr = n_ptr->active_links[selector & 1]; | 3236 | l_ptr = n_ptr->active_links[selector & 1]; |
| 3264 | if (l_ptr) | 3237 | if (l_ptr) |
| 3265 | res = link_max_pkt(l_ptr); | 3238 | res = l_ptr->max_pkt; |
| 3266 | tipc_node_unlock(n_ptr); | 3239 | tipc_node_unlock(n_ptr); |
| 3267 | } | 3240 | } |
| 3268 | read_unlock_bh(&tipc_net_lock); | 3241 | read_unlock_bh(&tipc_net_lock); |
| @@ -3285,7 +3258,7 @@ static void link_dump_rec_queue(struct link *l_ptr) | |||
| 3285 | info("buffer %x invalid\n", crs); | 3258 | info("buffer %x invalid\n", crs); |
| 3286 | return; | 3259 | return; |
| 3287 | } | 3260 | } |
| 3288 | msg_dbg(buf_msg(crs), "In rec queue: \n"); | 3261 | msg_dbg(buf_msg(crs), "In rec queue:\n"); |
| 3289 | crs = crs->next; | 3262 | crs = crs->next; |
| 3290 | } | 3263 | } |
| 3291 | } | 3264 | } |
| @@ -3320,9 +3293,7 @@ static void link_print(struct link *l_ptr, struct print_buf *buf, | |||
| 3320 | if (l_ptr->next_out) | 3293 | if (l_ptr->next_out) |
| 3321 | tipc_printf(buf, "%u..", | 3294 | tipc_printf(buf, "%u..", |
| 3322 | msg_seqno(buf_msg(l_ptr->next_out))); | 3295 | msg_seqno(buf_msg(l_ptr->next_out))); |
| 3323 | tipc_printf(buf, "%u]", | 3296 | tipc_printf(buf, "%u]", msg_seqno(buf_msg(l_ptr->last_out))); |
| 3324 | msg_seqno(buf_msg | ||
| 3325 | (l_ptr->last_out)), l_ptr->out_queue_size); | ||
| 3326 | if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) - | 3297 | if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) - |
| 3327 | msg_seqno(buf_msg(l_ptr->first_out))) | 3298 | msg_seqno(buf_msg(l_ptr->first_out))) |
| 3328 | != (l_ptr->out_queue_size - 1)) || | 3299 | != (l_ptr->out_queue_size - 1)) || |
diff --git a/net/tipc/link.h b/net/tipc/link.h index 6a51e38ad25c..2e5385c47d30 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h | |||
| @@ -292,4 +292,39 @@ static inline u32 lesser(u32 left, u32 right) | |||
| 292 | return less_eq(left, right) ? left : right; | 292 | return less_eq(left, right) ? left : right; |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | |||
| 296 | /* | ||
| 297 | * Link status checking routines | ||
| 298 | */ | ||
| 299 | |||
| 300 | static inline int link_working_working(struct link *l_ptr) | ||
| 301 | { | ||
| 302 | return (l_ptr->state == WORKING_WORKING); | ||
| 303 | } | ||
| 304 | |||
| 305 | static inline int link_working_unknown(struct link *l_ptr) | ||
| 306 | { | ||
| 307 | return (l_ptr->state == WORKING_UNKNOWN); | ||
| 308 | } | ||
| 309 | |||
| 310 | static inline int link_reset_unknown(struct link *l_ptr) | ||
| 311 | { | ||
| 312 | return (l_ptr->state == RESET_UNKNOWN); | ||
| 313 | } | ||
| 314 | |||
| 315 | static inline int link_reset_reset(struct link *l_ptr) | ||
| 316 | { | ||
| 317 | return (l_ptr->state == RESET_RESET); | ||
| 318 | } | ||
| 319 | |||
| 320 | static inline int link_blocked(struct link *l_ptr) | ||
| 321 | { | ||
| 322 | return (l_ptr->exp_msg_count || l_ptr->blocked); | ||
| 323 | } | ||
| 324 | |||
| 325 | static inline int link_congested(struct link *l_ptr) | ||
| 326 | { | ||
| 327 | return (l_ptr->out_queue_size >= l_ptr->queue_limit[0]); | ||
| 328 | } | ||
| 329 | |||
| 295 | #endif | 330 | #endif |
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 73dcd00d674e..381063817b41 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c | |||
| @@ -40,6 +40,100 @@ | |||
| 40 | #include "msg.h" | 40 | #include "msg.h" |
| 41 | #include "bearer.h" | 41 | #include "bearer.h" |
| 42 | 42 | ||
| 43 | u32 tipc_msg_tot_importance(struct tipc_msg *m) | ||
| 44 | { | ||
| 45 | if (likely(msg_isdata(m))) { | ||
| 46 | if (likely(msg_orignode(m) == tipc_own_addr)) | ||
| 47 | return msg_importance(m); | ||
| 48 | return msg_importance(m) + 4; | ||
| 49 | } | ||
| 50 | if ((msg_user(m) == MSG_FRAGMENTER) && | ||
| 51 | (msg_type(m) == FIRST_FRAGMENT)) | ||
| 52 | return msg_importance(msg_get_wrapped(m)); | ||
| 53 | return msg_importance(m); | ||
| 54 | } | ||
| 55 | |||
| 56 | |||
| 57 | void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, | ||
| 58 | u32 hsize, u32 destnode) | ||
| 59 | { | ||
| 60 | memset(m, 0, hsize); | ||
| 61 | msg_set_version(m); | ||
| 62 | msg_set_user(m, user); | ||
| 63 | msg_set_hdr_sz(m, hsize); | ||
| 64 | msg_set_size(m, hsize); | ||
| 65 | msg_set_prevnode(m, tipc_own_addr); | ||
| 66 | msg_set_type(m, type); | ||
| 67 | if (!msg_short(m)) { | ||
| 68 | msg_set_orignode(m, tipc_own_addr); | ||
| 69 | msg_set_destnode(m, destnode); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | /** | ||
| 74 | * tipc_msg_calc_data_size - determine total data size for message | ||
| 75 | */ | ||
| 76 | |||
| 77 | int tipc_msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect) | ||
| 78 | { | ||
| 79 | int dsz = 0; | ||
| 80 | int i; | ||
| 81 | |||
| 82 | for (i = 0; i < num_sect; i++) | ||
| 83 | dsz += msg_sect[i].iov_len; | ||
| 84 | return dsz; | ||
| 85 | } | ||
| 86 | |||
| 87 | /** | ||
| 88 | * tipc_msg_build - create message using specified header and data | ||
| 89 | * | ||
| 90 | * Note: Caller must not hold any locks in case copy_from_user() is interrupted! | ||
| 91 | * | ||
| 92 | * Returns message data size or errno | ||
| 93 | */ | ||
| 94 | |||
| 95 | int tipc_msg_build(struct tipc_msg *hdr, | ||
| 96 | struct iovec const *msg_sect, u32 num_sect, | ||
| 97 | int max_size, int usrmem, struct sk_buff** buf) | ||
| 98 | { | ||
| 99 | int dsz, sz, hsz, pos, res, cnt; | ||
| 100 | |||
| 101 | dsz = tipc_msg_calc_data_size(msg_sect, num_sect); | ||
| 102 | if (unlikely(dsz > TIPC_MAX_USER_MSG_SIZE)) { | ||
| 103 | *buf = NULL; | ||
| 104 | return -EINVAL; | ||
| 105 | } | ||
| 106 | |||
| 107 | pos = hsz = msg_hdr_sz(hdr); | ||
| 108 | sz = hsz + dsz; | ||
| 109 | msg_set_size(hdr, sz); | ||
| 110 | if (unlikely(sz > max_size)) { | ||
| 111 | *buf = NULL; | ||
| 112 | return dsz; | ||
| 113 | } | ||
| 114 | |||
| 115 | *buf = buf_acquire(sz); | ||
| 116 | if (!(*buf)) | ||
| 117 | return -ENOMEM; | ||
| 118 | skb_copy_to_linear_data(*buf, hdr, hsz); | ||
| 119 | for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) { | ||
| 120 | if (likely(usrmem)) | ||
| 121 | res = !copy_from_user((*buf)->data + pos, | ||
| 122 | msg_sect[cnt].iov_base, | ||
| 123 | msg_sect[cnt].iov_len); | ||
| 124 | else | ||
| 125 | skb_copy_to_linear_data_offset(*buf, pos, | ||
| 126 | msg_sect[cnt].iov_base, | ||
| 127 | msg_sect[cnt].iov_len); | ||
| 128 | pos += msg_sect[cnt].iov_len; | ||
| 129 | } | ||
| 130 | if (likely(res)) | ||
| 131 | return dsz; | ||
| 132 | |||
| 133 | buf_discard(*buf); | ||
| 134 | *buf = NULL; | ||
| 135 | return -EFAULT; | ||
| 136 | } | ||
| 43 | 137 | ||
| 44 | #ifdef CONFIG_TIPC_DEBUG | 138 | #ifdef CONFIG_TIPC_DEBUG |
| 45 | 139 | ||
diff --git a/net/tipc/msg.h b/net/tipc/msg.h index 7ee6ae238147..995d2da35b01 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h | |||
| @@ -708,100 +708,13 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos) | |||
| 708 | #define DSC_REQ_MSG 0 | 708 | #define DSC_REQ_MSG 0 |
| 709 | #define DSC_RESP_MSG 1 | 709 | #define DSC_RESP_MSG 1 |
| 710 | 710 | ||
| 711 | static inline u32 msg_tot_importance(struct tipc_msg *m) | 711 | u32 tipc_msg_tot_importance(struct tipc_msg *m); |
| 712 | { | 712 | void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, |
| 713 | if (likely(msg_isdata(m))) { | 713 | u32 hsize, u32 destnode); |
| 714 | if (likely(msg_orignode(m) == tipc_own_addr)) | 714 | int tipc_msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect); |
| 715 | return msg_importance(m); | 715 | int tipc_msg_build(struct tipc_msg *hdr, |
| 716 | return msg_importance(m) + 4; | ||
| 717 | } | ||
| 718 | if ((msg_user(m) == MSG_FRAGMENTER) && | ||
| 719 | (msg_type(m) == FIRST_FRAGMENT)) | ||
| 720 | return msg_importance(msg_get_wrapped(m)); | ||
| 721 | return msg_importance(m); | ||
| 722 | } | ||
| 723 | |||
| 724 | |||
| 725 | static inline void msg_init(struct tipc_msg *m, u32 user, u32 type, | ||
| 726 | u32 hsize, u32 destnode) | ||
| 727 | { | ||
| 728 | memset(m, 0, hsize); | ||
| 729 | msg_set_version(m); | ||
| 730 | msg_set_user(m, user); | ||
| 731 | msg_set_hdr_sz(m, hsize); | ||
| 732 | msg_set_size(m, hsize); | ||
| 733 | msg_set_prevnode(m, tipc_own_addr); | ||
| 734 | msg_set_type(m, type); | ||
| 735 | if (!msg_short(m)) { | ||
| 736 | msg_set_orignode(m, tipc_own_addr); | ||
| 737 | msg_set_destnode(m, destnode); | ||
| 738 | } | ||
| 739 | } | ||
| 740 | |||
| 741 | /** | ||
| 742 | * msg_calc_data_size - determine total data size for message | ||
| 743 | */ | ||
| 744 | |||
| 745 | static inline int msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect) | ||
| 746 | { | ||
| 747 | int dsz = 0; | ||
| 748 | int i; | ||
| 749 | |||
| 750 | for (i = 0; i < num_sect; i++) | ||
| 751 | dsz += msg_sect[i].iov_len; | ||
| 752 | return dsz; | ||
| 753 | } | ||
| 754 | |||
| 755 | /** | ||
| 756 | * msg_build - create message using specified header and data | ||
| 757 | * | ||
| 758 | * Note: Caller must not hold any locks in case copy_from_user() is interrupted! | ||
| 759 | * | ||
| 760 | * Returns message data size or errno | ||
| 761 | */ | ||
| 762 | |||
| 763 | static inline int msg_build(struct tipc_msg *hdr, | ||
| 764 | struct iovec const *msg_sect, u32 num_sect, | 716 | struct iovec const *msg_sect, u32 num_sect, |
| 765 | int max_size, int usrmem, struct sk_buff** buf) | 717 | int max_size, int usrmem, struct sk_buff** buf); |
| 766 | { | ||
| 767 | int dsz, sz, hsz, pos, res, cnt; | ||
| 768 | |||
| 769 | dsz = msg_calc_data_size(msg_sect, num_sect); | ||
| 770 | if (unlikely(dsz > TIPC_MAX_USER_MSG_SIZE)) { | ||
| 771 | *buf = NULL; | ||
| 772 | return -EINVAL; | ||
| 773 | } | ||
| 774 | |||
| 775 | pos = hsz = msg_hdr_sz(hdr); | ||
| 776 | sz = hsz + dsz; | ||
| 777 | msg_set_size(hdr, sz); | ||
| 778 | if (unlikely(sz > max_size)) { | ||
| 779 | *buf = NULL; | ||
| 780 | return dsz; | ||
| 781 | } | ||
| 782 | |||
| 783 | *buf = buf_acquire(sz); | ||
| 784 | if (!(*buf)) | ||
| 785 | return -ENOMEM; | ||
| 786 | skb_copy_to_linear_data(*buf, hdr, hsz); | ||
| 787 | for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) { | ||
| 788 | if (likely(usrmem)) | ||
| 789 | res = !copy_from_user((*buf)->data + pos, | ||
| 790 | msg_sect[cnt].iov_base, | ||
| 791 | msg_sect[cnt].iov_len); | ||
| 792 | else | ||
| 793 | skb_copy_to_linear_data_offset(*buf, pos, | ||
| 794 | msg_sect[cnt].iov_base, | ||
| 795 | msg_sect[cnt].iov_len); | ||
| 796 | pos += msg_sect[cnt].iov_len; | ||
| 797 | } | ||
| 798 | if (likely(res)) | ||
| 799 | return dsz; | ||
| 800 | |||
| 801 | buf_discard(*buf); | ||
| 802 | *buf = NULL; | ||
| 803 | return -EFAULT; | ||
| 804 | } | ||
| 805 | 718 | ||
| 806 | static inline void msg_set_media_addr(struct tipc_msg *m, struct tipc_media_addr *a) | 719 | static inline void msg_set_media_addr(struct tipc_msg *m, struct tipc_media_addr *a) |
| 807 | { | 720 | { |
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index 10a69894e2fd..6ac3c543250b 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c | |||
| @@ -103,7 +103,7 @@ static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest) | |||
| 103 | 103 | ||
| 104 | if (buf != NULL) { | 104 | if (buf != NULL) { |
| 105 | msg = buf_msg(buf); | 105 | msg = buf_msg(buf); |
| 106 | msg_init(msg, NAME_DISTRIBUTOR, type, LONG_H_SIZE, dest); | 106 | tipc_msg_init(msg, NAME_DISTRIBUTOR, type, LONG_H_SIZE, dest); |
| 107 | msg_set_size(msg, LONG_H_SIZE + size); | 107 | msg_set_size(msg, LONG_H_SIZE + size); |
| 108 | } | 108 | } |
| 109 | return buf; | 109 | return buf; |
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index acab41a48d67..8ba79620db3f 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
| @@ -627,7 +627,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) | |||
| 627 | struct name_seq *seq; | 627 | struct name_seq *seq; |
| 628 | u32 ref; | 628 | u32 ref; |
| 629 | 629 | ||
| 630 | if (!in_scope(*destnode, tipc_own_addr)) | 630 | if (!tipc_in_scope(*destnode, tipc_own_addr)) |
| 631 | return 0; | 631 | return 0; |
| 632 | 632 | ||
| 633 | read_lock_bh(&tipc_nametbl_lock); | 633 | read_lock_bh(&tipc_nametbl_lock); |
diff --git a/net/tipc/net.c b/net/tipc/net.c index 7906608bf510..f61b7694138b 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
| @@ -116,7 +116,8 @@ | |||
| 116 | */ | 116 | */ |
| 117 | 117 | ||
| 118 | DEFINE_RWLOCK(tipc_net_lock); | 118 | DEFINE_RWLOCK(tipc_net_lock); |
| 119 | struct network tipc_net = { NULL }; | 119 | static struct _zone *tipc_zones[256] = { NULL, }; |
| 120 | struct network tipc_net = { tipc_zones }; | ||
| 120 | 121 | ||
| 121 | struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref) | 122 | struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref) |
| 122 | { | 123 | { |
| @@ -158,28 +159,12 @@ void tipc_net_send_external_routes(u32 dest) | |||
| 158 | } | 159 | } |
| 159 | } | 160 | } |
| 160 | 161 | ||
| 161 | static int net_init(void) | ||
| 162 | { | ||
| 163 | memset(&tipc_net, 0, sizeof(tipc_net)); | ||
| 164 | tipc_net.zones = kcalloc(tipc_max_zones + 1, sizeof(struct _zone *), GFP_ATOMIC); | ||
| 165 | if (!tipc_net.zones) { | ||
| 166 | return -ENOMEM; | ||
| 167 | } | ||
| 168 | return 0; | ||
| 169 | } | ||
| 170 | |||
| 171 | static void net_stop(void) | 162 | static void net_stop(void) |
| 172 | { | 163 | { |
| 173 | u32 z_num; | 164 | u32 z_num; |
| 174 | 165 | ||
| 175 | if (!tipc_net.zones) | 166 | for (z_num = 1; z_num <= tipc_max_zones; z_num++) |
| 176 | return; | ||
| 177 | |||
| 178 | for (z_num = 1; z_num <= tipc_max_zones; z_num++) { | ||
| 179 | tipc_zone_delete(tipc_net.zones[z_num]); | 167 | tipc_zone_delete(tipc_net.zones[z_num]); |
| 180 | } | ||
| 181 | kfree(tipc_net.zones); | ||
| 182 | tipc_net.zones = NULL; | ||
| 183 | } | 168 | } |
| 184 | 169 | ||
| 185 | static void net_route_named_msg(struct sk_buff *buf) | 170 | static void net_route_named_msg(struct sk_buff *buf) |
| @@ -234,7 +219,7 @@ void tipc_net_route_msg(struct sk_buff *buf) | |||
| 234 | 219 | ||
| 235 | /* Handle message for this node */ | 220 | /* Handle message for this node */ |
| 236 | dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg); | 221 | dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg); |
| 237 | if (in_scope(dnode, tipc_own_addr)) { | 222 | if (tipc_in_scope(dnode, tipc_own_addr)) { |
| 238 | if (msg_isdata(msg)) { | 223 | if (msg_isdata(msg)) { |
| 239 | if (msg_mcast(msg)) | 224 | if (msg_mcast(msg)) |
| 240 | tipc_port_recv_mcast(buf, NULL); | 225 | tipc_port_recv_mcast(buf, NULL); |
| @@ -282,9 +267,7 @@ int tipc_net_start(u32 addr) | |||
| 282 | tipc_named_reinit(); | 267 | tipc_named_reinit(); |
| 283 | tipc_port_reinit(); | 268 | tipc_port_reinit(); |
| 284 | 269 | ||
| 285 | if ((res = tipc_bearer_init()) || | 270 | if ((res = tipc_cltr_init()) || |
| 286 | (res = net_init()) || | ||
| 287 | (res = tipc_cltr_init()) || | ||
| 288 | (res = tipc_bclink_init())) { | 271 | (res = tipc_bclink_init())) { |
| 289 | return res; | 272 | return res; |
| 290 | } | 273 | } |
| @@ -294,7 +277,7 @@ int tipc_net_start(u32 addr) | |||
| 294 | 277 | ||
| 295 | info("Started in network mode\n"); | 278 | info("Started in network mode\n"); |
| 296 | info("Own node address %s, network identity %u\n", | 279 | info("Own node address %s, network identity %u\n", |
| 297 | addr_string_fill(addr_string, tipc_own_addr), tipc_net_id); | 280 | tipc_addr_string_fill(addr_string, tipc_own_addr), tipc_net_id); |
| 298 | return 0; | 281 | return 0; |
| 299 | } | 282 | } |
| 300 | 283 | ||
| @@ -308,6 +291,6 @@ void tipc_net_stop(void) | |||
| 308 | tipc_bclink_stop(); | 291 | tipc_bclink_stop(); |
| 309 | net_stop(); | 292 | net_stop(); |
| 310 | write_unlock_bh(&tipc_net_lock); | 293 | write_unlock_bh(&tipc_net_lock); |
| 311 | info("Left network mode \n"); | 294 | info("Left network mode\n"); |
| 312 | } | 295 | } |
| 313 | 296 | ||
diff --git a/net/tipc/node.c b/net/tipc/node.c index 2c24e7d6d950..b634942caba5 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
| @@ -268,7 +268,7 @@ struct tipc_node *tipc_node_attach_link(struct link *l_ptr) | |||
| 268 | 268 | ||
| 269 | if (n_ptr->link_cnt >= 2) { | 269 | if (n_ptr->link_cnt >= 2) { |
| 270 | err("Attempt to create third link to %s\n", | 270 | err("Attempt to create third link to %s\n", |
| 271 | addr_string_fill(addr_string, n_ptr->addr)); | 271 | tipc_addr_string_fill(addr_string, n_ptr->addr)); |
| 272 | return NULL; | 272 | return NULL; |
| 273 | } | 273 | } |
| 274 | 274 | ||
| @@ -278,9 +278,9 @@ struct tipc_node *tipc_node_attach_link(struct link *l_ptr) | |||
| 278 | n_ptr->link_cnt++; | 278 | n_ptr->link_cnt++; |
| 279 | return n_ptr; | 279 | return n_ptr; |
| 280 | } | 280 | } |
| 281 | err("Attempt to establish second link on <%s> to %s \n", | 281 | err("Attempt to establish second link on <%s> to %s\n", |
| 282 | l_ptr->b_ptr->publ.name, | 282 | l_ptr->b_ptr->publ.name, |
| 283 | addr_string_fill(addr_string, l_ptr->addr)); | 283 | tipc_addr_string_fill(addr_string, l_ptr->addr)); |
| 284 | } | 284 | } |
| 285 | return NULL; | 285 | return NULL; |
| 286 | } | 286 | } |
| @@ -439,7 +439,7 @@ static void node_lost_contact(struct tipc_node *n_ptr) | |||
| 439 | return; | 439 | return; |
| 440 | 440 | ||
| 441 | info("Lost contact with %s\n", | 441 | info("Lost contact with %s\n", |
| 442 | addr_string_fill(addr_string, n_ptr->addr)); | 442 | tipc_addr_string_fill(addr_string, n_ptr->addr)); |
| 443 | 443 | ||
| 444 | /* Abort link changeover */ | 444 | /* Abort link changeover */ |
| 445 | for (i = 0; i < MAX_BEARERS; i++) { | 445 | for (i = 0; i < MAX_BEARERS; i++) { |
| @@ -602,7 +602,7 @@ u32 tipc_available_nodes(const u32 domain) | |||
| 602 | 602 | ||
| 603 | read_lock_bh(&tipc_net_lock); | 603 | read_lock_bh(&tipc_net_lock); |
| 604 | for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { | 604 | for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { |
| 605 | if (!in_scope(domain, n_ptr->addr)) | 605 | if (!tipc_in_scope(domain, n_ptr->addr)) |
| 606 | continue; | 606 | continue; |
| 607 | if (tipc_node_is_up(n_ptr)) | 607 | if (tipc_node_is_up(n_ptr)) |
| 608 | cnt++; | 608 | cnt++; |
| @@ -651,7 +651,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
| 651 | /* Add TLVs for all nodes in scope */ | 651 | /* Add TLVs for all nodes in scope */ |
| 652 | 652 | ||
| 653 | for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { | 653 | for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { |
| 654 | if (!in_scope(domain, n_ptr->addr)) | 654 | if (!tipc_in_scope(domain, n_ptr->addr)) |
| 655 | continue; | 655 | continue; |
| 656 | node_info.addr = htonl(n_ptr->addr); | 656 | node_info.addr = htonl(n_ptr->addr); |
| 657 | node_info.up = htonl(tipc_node_is_up(n_ptr)); | 657 | node_info.up = htonl(tipc_node_is_up(n_ptr)); |
| @@ -711,7 +711,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
| 711 | for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { | 711 | for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { |
| 712 | u32 i; | 712 | u32 i; |
| 713 | 713 | ||
| 714 | if (!in_scope(domain, n_ptr->addr)) | 714 | if (!tipc_in_scope(domain, n_ptr->addr)) |
| 715 | continue; | 715 | continue; |
| 716 | tipc_node_lock(n_ptr); | 716 | tipc_node_lock(n_ptr); |
| 717 | for (i = 0; i < MAX_BEARERS; i++) { | 717 | for (i = 0; i < MAX_BEARERS; i++) { |
diff --git a/net/tipc/port.c b/net/tipc/port.c index e70d27ea6578..0737680e9266 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c | |||
| @@ -116,7 +116,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain, | |||
| 116 | msg_set_namelower(hdr, seq->lower); | 116 | msg_set_namelower(hdr, seq->lower); |
| 117 | msg_set_nameupper(hdr, seq->upper); | 117 | msg_set_nameupper(hdr, seq->upper); |
| 118 | msg_set_hdr_sz(hdr, MCAST_H_SIZE); | 118 | msg_set_hdr_sz(hdr, MCAST_H_SIZE); |
| 119 | res = msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE, | 119 | res = tipc_msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE, |
| 120 | !oport->user_port, &buf); | 120 | !oport->user_port, &buf); |
| 121 | if (unlikely(!buf)) | 121 | if (unlikely(!buf)) |
| 122 | return res; | 122 | return res; |
| @@ -241,13 +241,12 @@ struct tipc_port *tipc_createport_raw(void *usr_handle, | |||
| 241 | p_ptr->publ.max_pkt = MAX_PKT_DEFAULT; | 241 | p_ptr->publ.max_pkt = MAX_PKT_DEFAULT; |
| 242 | p_ptr->publ.ref = ref; | 242 | p_ptr->publ.ref = ref; |
| 243 | msg = &p_ptr->publ.phdr; | 243 | msg = &p_ptr->publ.phdr; |
| 244 | msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0); | 244 | tipc_msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0); |
| 245 | msg_set_origport(msg, ref); | 245 | msg_set_origport(msg, ref); |
| 246 | p_ptr->last_in_seqno = 41; | 246 | p_ptr->last_in_seqno = 41; |
| 247 | p_ptr->sent = 1; | 247 | p_ptr->sent = 1; |
| 248 | INIT_LIST_HEAD(&p_ptr->wait_list); | 248 | INIT_LIST_HEAD(&p_ptr->wait_list); |
| 249 | INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); | 249 | INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); |
| 250 | p_ptr->congested_link = NULL; | ||
| 251 | p_ptr->dispatcher = dispatcher; | 250 | p_ptr->dispatcher = dispatcher; |
| 252 | p_ptr->wakeup = wakeup; | 251 | p_ptr->wakeup = wakeup; |
| 253 | p_ptr->user_port = NULL; | 252 | p_ptr->user_port = NULL; |
| @@ -396,7 +395,7 @@ static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode, | |||
| 396 | buf = buf_acquire(LONG_H_SIZE); | 395 | buf = buf_acquire(LONG_H_SIZE); |
| 397 | if (buf) { | 396 | if (buf) { |
| 398 | msg = buf_msg(buf); | 397 | msg = buf_msg(buf); |
| 399 | msg_init(msg, usr, type, LONG_H_SIZE, destnode); | 398 | tipc_msg_init(msg, usr, type, LONG_H_SIZE, destnode); |
| 400 | msg_set_errcode(msg, err); | 399 | msg_set_errcode(msg, err); |
| 401 | msg_set_destport(msg, destport); | 400 | msg_set_destport(msg, destport); |
| 402 | msg_set_origport(msg, origport); | 401 | msg_set_origport(msg, origport); |
| @@ -440,7 +439,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) | |||
| 440 | return data_sz; | 439 | return data_sz; |
| 441 | } | 440 | } |
| 442 | rmsg = buf_msg(rbuf); | 441 | rmsg = buf_msg(rbuf); |
| 443 | msg_init(rmsg, imp, msg_type(msg), hdr_sz, msg_orignode(msg)); | 442 | tipc_msg_init(rmsg, imp, msg_type(msg), hdr_sz, msg_orignode(msg)); |
| 444 | msg_set_errcode(rmsg, err); | 443 | msg_set_errcode(rmsg, err); |
| 445 | msg_set_destport(rmsg, msg_origport(msg)); | 444 | msg_set_destport(rmsg, msg_origport(msg)); |
| 446 | msg_set_origport(rmsg, msg_destport(msg)); | 445 | msg_set_origport(rmsg, msg_destport(msg)); |
| @@ -481,7 +480,7 @@ int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, | |||
| 481 | struct sk_buff *buf; | 480 | struct sk_buff *buf; |
| 482 | int res; | 481 | int res; |
| 483 | 482 | ||
| 484 | res = msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE, | 483 | res = tipc_msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE, |
| 485 | !p_ptr->user_port, &buf); | 484 | !p_ptr->user_port, &buf); |
| 486 | if (!buf) | 485 | if (!buf) |
| 487 | return res; | 486 | return res; |
| @@ -1344,7 +1343,7 @@ int tipc_port_recv_sections(struct port *sender, unsigned int num_sect, | |||
| 1344 | struct sk_buff *buf; | 1343 | struct sk_buff *buf; |
| 1345 | int res; | 1344 | int res; |
| 1346 | 1345 | ||
| 1347 | res = msg_build(&sender->publ.phdr, msg_sect, num_sect, | 1346 | res = tipc_msg_build(&sender->publ.phdr, msg_sect, num_sect, |
| 1348 | MAX_MSG_SIZE, !sender->user_port, &buf); | 1347 | MAX_MSG_SIZE, !sender->user_port, &buf); |
| 1349 | if (likely(buf)) | 1348 | if (likely(buf)) |
| 1350 | tipc_port_recv_msg(buf); | 1349 | tipc_port_recv_msg(buf); |
| @@ -1384,7 +1383,7 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect) | |||
| 1384 | if (port_unreliable(p_ptr)) { | 1383 | if (port_unreliable(p_ptr)) { |
| 1385 | p_ptr->publ.congested = 0; | 1384 | p_ptr->publ.congested = 0; |
| 1386 | /* Just calculate msg length and return */ | 1385 | /* Just calculate msg length and return */ |
| 1387 | return msg_calc_data_size(msg_sect, num_sect); | 1386 | return tipc_msg_calc_data_size(msg_sect, num_sect); |
| 1388 | } | 1387 | } |
| 1389 | return -ELINKCONG; | 1388 | return -ELINKCONG; |
| 1390 | } | 1389 | } |
| @@ -1453,7 +1452,7 @@ int tipc_forward2name(u32 ref, | |||
| 1453 | struct port *p_ptr; | 1452 | struct port *p_ptr; |
| 1454 | struct tipc_msg *msg; | 1453 | struct tipc_msg *msg; |
| 1455 | u32 destnode = domain; | 1454 | u32 destnode = domain; |
| 1456 | u32 destport = 0; | 1455 | u32 destport; |
| 1457 | int res; | 1456 | int res; |
| 1458 | 1457 | ||
| 1459 | p_ptr = tipc_port_deref(ref); | 1458 | p_ptr = tipc_port_deref(ref); |
| @@ -1467,7 +1466,7 @@ int tipc_forward2name(u32 ref, | |||
| 1467 | msg_set_hdr_sz(msg, LONG_H_SIZE); | 1466 | msg_set_hdr_sz(msg, LONG_H_SIZE); |
| 1468 | msg_set_nametype(msg, name->type); | 1467 | msg_set_nametype(msg, name->type); |
| 1469 | msg_set_nameinst(msg, name->instance); | 1468 | msg_set_nameinst(msg, name->instance); |
| 1470 | msg_set_lookup_scope(msg, addr_scope(domain)); | 1469 | msg_set_lookup_scope(msg, tipc_addr_scope(domain)); |
| 1471 | if (importance <= TIPC_CRITICAL_IMPORTANCE) | 1470 | if (importance <= TIPC_CRITICAL_IMPORTANCE) |
| 1472 | msg_set_importance(msg,importance); | 1471 | msg_set_importance(msg,importance); |
| 1473 | destport = tipc_nametbl_translate(name->type, name->instance, &destnode); | 1472 | destport = tipc_nametbl_translate(name->type, name->instance, &destnode); |
| @@ -1484,7 +1483,7 @@ int tipc_forward2name(u32 ref, | |||
| 1484 | return res; | 1483 | return res; |
| 1485 | if (port_unreliable(p_ptr)) { | 1484 | if (port_unreliable(p_ptr)) { |
| 1486 | /* Just calculate msg length and return */ | 1485 | /* Just calculate msg length and return */ |
| 1487 | return msg_calc_data_size(msg_sect, num_sect); | 1486 | return tipc_msg_calc_data_size(msg_sect, num_sect); |
| 1488 | } | 1487 | } |
| 1489 | return -ELINKCONG; | 1488 | return -ELINKCONG; |
| 1490 | } | 1489 | } |
| @@ -1525,7 +1524,7 @@ int tipc_forward_buf2name(u32 ref, | |||
| 1525 | struct port *p_ptr; | 1524 | struct port *p_ptr; |
| 1526 | struct tipc_msg *msg; | 1525 | struct tipc_msg *msg; |
| 1527 | u32 destnode = domain; | 1526 | u32 destnode = domain; |
| 1528 | u32 destport = 0; | 1527 | u32 destport; |
| 1529 | int res; | 1528 | int res; |
| 1530 | 1529 | ||
| 1531 | p_ptr = (struct port *)tipc_ref_deref(ref); | 1530 | p_ptr = (struct port *)tipc_ref_deref(ref); |
| @@ -1540,7 +1539,7 @@ int tipc_forward_buf2name(u32 ref, | |||
| 1540 | msg_set_origport(msg, orig->ref); | 1539 | msg_set_origport(msg, orig->ref); |
| 1541 | msg_set_nametype(msg, name->type); | 1540 | msg_set_nametype(msg, name->type); |
| 1542 | msg_set_nameinst(msg, name->instance); | 1541 | msg_set_nameinst(msg, name->instance); |
| 1543 | msg_set_lookup_scope(msg, addr_scope(domain)); | 1542 | msg_set_lookup_scope(msg, tipc_addr_scope(domain)); |
| 1544 | msg_set_hdr_sz(msg, LONG_H_SIZE); | 1543 | msg_set_hdr_sz(msg, LONG_H_SIZE); |
| 1545 | msg_set_size(msg, LONG_H_SIZE + dsz); | 1544 | msg_set_size(msg, LONG_H_SIZE + dsz); |
| 1546 | destport = tipc_nametbl_translate(name->type, name->instance, &destnode); | 1545 | destport = tipc_nametbl_translate(name->type, name->instance, &destnode); |
| @@ -1620,7 +1619,7 @@ int tipc_forward2port(u32 ref, | |||
| 1620 | return res; | 1619 | return res; |
| 1621 | if (port_unreliable(p_ptr)) { | 1620 | if (port_unreliable(p_ptr)) { |
| 1622 | /* Just calculate msg length and return */ | 1621 | /* Just calculate msg length and return */ |
| 1623 | return msg_calc_data_size(msg_sect, num_sect); | 1622 | return tipc_msg_calc_data_size(msg_sect, num_sect); |
| 1624 | } | 1623 | } |
| 1625 | return -ELINKCONG; | 1624 | return -ELINKCONG; |
| 1626 | } | 1625 | } |
diff --git a/net/tipc/port.h b/net/tipc/port.h index ff31ee4a1dc3..8d1652aab298 100644 --- a/net/tipc/port.h +++ b/net/tipc/port.h | |||
| @@ -75,7 +75,6 @@ struct user_port { | |||
| 75 | * @wakeup: ptr to routine to call when port is no longer congested | 75 | * @wakeup: ptr to routine to call when port is no longer congested |
| 76 | * @user_port: ptr to user port associated with port (if any) | 76 | * @user_port: ptr to user port associated with port (if any) |
| 77 | * @wait_list: adjacent ports in list of ports waiting on link congestion | 77 | * @wait_list: adjacent ports in list of ports waiting on link congestion |
| 78 | * @congested_link: ptr to congested link port is waiting on | ||
| 79 | * @waiting_pkts: | 78 | * @waiting_pkts: |
| 80 | * @sent: | 79 | * @sent: |
| 81 | * @acked: | 80 | * @acked: |
| @@ -95,7 +94,6 @@ struct port { | |||
| 95 | void (*wakeup)(struct tipc_port *); | 94 | void (*wakeup)(struct tipc_port *); |
| 96 | struct user_port *user_port; | 95 | struct user_port *user_port; |
| 97 | struct list_head wait_list; | 96 | struct list_head wait_list; |
| 98 | struct link *congested_link; | ||
| 99 | u32 waiting_pkts; | 97 | u32 waiting_pkts; |
| 100 | u32 sent; | 98 | u32 sent; |
| 101 | u32 acked; | 99 | u32 acked; |
diff --git a/net/tipc/ref.c b/net/tipc/ref.c index 414fc34b8bea..8dea66500cf5 100644 --- a/net/tipc/ref.c +++ b/net/tipc/ref.c | |||
| @@ -153,11 +153,11 @@ void tipc_ref_table_stop(void) | |||
| 153 | 153 | ||
| 154 | u32 tipc_ref_acquire(void *object, spinlock_t **lock) | 154 | u32 tipc_ref_acquire(void *object, spinlock_t **lock) |
| 155 | { | 155 | { |
| 156 | struct reference *entry; | ||
| 157 | u32 index; | 156 | u32 index; |
| 158 | u32 index_mask; | 157 | u32 index_mask; |
| 159 | u32 next_plus_upper; | 158 | u32 next_plus_upper; |
| 160 | u32 ref; | 159 | u32 ref; |
| 160 | struct reference *entry = NULL; | ||
| 161 | 161 | ||
| 162 | if (!object) { | 162 | if (!object) { |
| 163 | err("Attempt to acquire reference to non-existent object\n"); | 163 | err("Attempt to acquire reference to non-existent object\n"); |
| @@ -175,30 +175,36 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock) | |||
| 175 | index = tipc_ref_table.first_free; | 175 | index = tipc_ref_table.first_free; |
| 176 | entry = &(tipc_ref_table.entries[index]); | 176 | entry = &(tipc_ref_table.entries[index]); |
| 177 | index_mask = tipc_ref_table.index_mask; | 177 | index_mask = tipc_ref_table.index_mask; |
| 178 | /* take lock in case a previous user of entry still holds it */ | ||
| 179 | spin_lock_bh(&entry->lock); | ||
| 180 | next_plus_upper = entry->ref; | 178 | next_plus_upper = entry->ref; |
| 181 | tipc_ref_table.first_free = next_plus_upper & index_mask; | 179 | tipc_ref_table.first_free = next_plus_upper & index_mask; |
| 182 | ref = (next_plus_upper & ~index_mask) + index; | 180 | ref = (next_plus_upper & ~index_mask) + index; |
| 183 | entry->ref = ref; | ||
| 184 | entry->object = object; | ||
| 185 | *lock = &entry->lock; | ||
| 186 | } | 181 | } |
| 187 | else if (tipc_ref_table.init_point < tipc_ref_table.capacity) { | 182 | else if (tipc_ref_table.init_point < tipc_ref_table.capacity) { |
| 188 | index = tipc_ref_table.init_point++; | 183 | index = tipc_ref_table.init_point++; |
| 189 | entry = &(tipc_ref_table.entries[index]); | 184 | entry = &(tipc_ref_table.entries[index]); |
| 190 | spin_lock_init(&entry->lock); | 185 | spin_lock_init(&entry->lock); |
| 191 | spin_lock_bh(&entry->lock); | ||
| 192 | ref = tipc_ref_table.start_mask + index; | 186 | ref = tipc_ref_table.start_mask + index; |
| 193 | entry->ref = ref; | ||
| 194 | entry->object = object; | ||
| 195 | *lock = &entry->lock; | ||
| 196 | } | 187 | } |
| 197 | else { | 188 | else { |
| 198 | ref = 0; | 189 | ref = 0; |
| 199 | } | 190 | } |
| 200 | write_unlock_bh(&ref_table_lock); | 191 | write_unlock_bh(&ref_table_lock); |
| 201 | 192 | ||
| 193 | /* | ||
| 194 | * Grab the lock so no one else can modify this entry | ||
| 195 | * While we assign its ref value & object pointer | ||
| 196 | */ | ||
| 197 | if (entry) { | ||
| 198 | spin_lock_bh(&entry->lock); | ||
| 199 | entry->ref = ref; | ||
| 200 | entry->object = object; | ||
| 201 | *lock = &entry->lock; | ||
| 202 | /* | ||
| 203 | * keep it locked, the caller is responsible | ||
| 204 | * for unlocking this when they're done with it | ||
| 205 | */ | ||
| 206 | } | ||
| 207 | |||
| 202 | return ref; | 208 | return ref; |
| 203 | } | 209 | } |
| 204 | 210 | ||
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 1ea64f09cc45..66e889ba48fd 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
| @@ -40,9 +40,9 @@ | |||
| 40 | #include <linux/socket.h> | 40 | #include <linux/socket.h> |
| 41 | #include <linux/errno.h> | 41 | #include <linux/errno.h> |
| 42 | #include <linux/mm.h> | 42 | #include <linux/mm.h> |
| 43 | #include <linux/slab.h> | ||
| 44 | #include <linux/poll.h> | 43 | #include <linux/poll.h> |
| 45 | #include <linux/fcntl.h> | 44 | #include <linux/fcntl.h> |
| 45 | #include <linux/gfp.h> | ||
| 46 | #include <asm/string.h> | 46 | #include <asm/string.h> |
| 47 | #include <asm/atomic.h> | 47 | #include <asm/atomic.h> |
| 48 | #include <net/sock.h> | 48 | #include <net/sock.h> |
| @@ -446,7 +446,7 @@ static unsigned int poll(struct file *file, struct socket *sock, | |||
| 446 | struct sock *sk = sock->sk; | 446 | struct sock *sk = sock->sk; |
| 447 | u32 mask; | 447 | u32 mask; |
| 448 | 448 | ||
| 449 | poll_wait(file, sk->sk_sleep, wait); | 449 | poll_wait(file, sk_sleep(sk), wait); |
| 450 | 450 | ||
| 451 | if (!skb_queue_empty(&sk->sk_receive_queue) || | 451 | if (!skb_queue_empty(&sk->sk_receive_queue) || |
| 452 | (sock->state == SS_UNCONNECTED) || | 452 | (sock->state == SS_UNCONNECTED) || |
| @@ -591,7 +591,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, | |||
| 591 | break; | 591 | break; |
| 592 | } | 592 | } |
| 593 | release_sock(sk); | 593 | release_sock(sk); |
| 594 | res = wait_event_interruptible(*sk->sk_sleep, | 594 | res = wait_event_interruptible(*sk_sleep(sk), |
| 595 | !tport->congested); | 595 | !tport->congested); |
| 596 | lock_sock(sk); | 596 | lock_sock(sk); |
| 597 | if (res) | 597 | if (res) |
| @@ -650,7 +650,7 @@ static int send_packet(struct kiocb *iocb, struct socket *sock, | |||
| 650 | break; | 650 | break; |
| 651 | } | 651 | } |
| 652 | release_sock(sk); | 652 | release_sock(sk); |
| 653 | res = wait_event_interruptible(*sk->sk_sleep, | 653 | res = wait_event_interruptible(*sk_sleep(sk), |
| 654 | (!tport->congested || !tport->connected)); | 654 | (!tport->congested || !tport->connected)); |
| 655 | lock_sock(sk); | 655 | lock_sock(sk); |
| 656 | if (res) | 656 | if (res) |
| @@ -931,7 +931,7 @@ restart: | |||
| 931 | goto exit; | 931 | goto exit; |
| 932 | } | 932 | } |
| 933 | release_sock(sk); | 933 | release_sock(sk); |
| 934 | res = wait_event_interruptible(*sk->sk_sleep, | 934 | res = wait_event_interruptible(*sk_sleep(sk), |
| 935 | (!skb_queue_empty(&sk->sk_receive_queue) || | 935 | (!skb_queue_empty(&sk->sk_receive_queue) || |
| 936 | (sock->state == SS_DISCONNECTING))); | 936 | (sock->state == SS_DISCONNECTING))); |
| 937 | lock_sock(sk); | 937 | lock_sock(sk); |
| @@ -1064,7 +1064,7 @@ restart: | |||
| 1064 | goto exit; | 1064 | goto exit; |
| 1065 | } | 1065 | } |
| 1066 | release_sock(sk); | 1066 | release_sock(sk); |
| 1067 | res = wait_event_interruptible(*sk->sk_sleep, | 1067 | res = wait_event_interruptible(*sk_sleep(sk), |
| 1068 | (!skb_queue_empty(&sk->sk_receive_queue) || | 1068 | (!skb_queue_empty(&sk->sk_receive_queue) || |
| 1069 | (sock->state == SS_DISCONNECTING))); | 1069 | (sock->state == SS_DISCONNECTING))); |
| 1070 | lock_sock(sk); | 1070 | lock_sock(sk); |
| @@ -1271,8 +1271,8 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf) | |||
| 1271 | tipc_disconnect_port(tipc_sk_port(sk)); | 1271 | tipc_disconnect_port(tipc_sk_port(sk)); |
| 1272 | } | 1272 | } |
| 1273 | 1273 | ||
| 1274 | if (waitqueue_active(sk->sk_sleep)) | 1274 | if (waitqueue_active(sk_sleep(sk))) |
| 1275 | wake_up_interruptible(sk->sk_sleep); | 1275 | wake_up_interruptible(sk_sleep(sk)); |
| 1276 | return TIPC_OK; | 1276 | return TIPC_OK; |
| 1277 | } | 1277 | } |
| 1278 | 1278 | ||
| @@ -1322,8 +1322,10 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf) | |||
| 1322 | if (!sock_owned_by_user(sk)) { | 1322 | if (!sock_owned_by_user(sk)) { |
| 1323 | res = filter_rcv(sk, buf); | 1323 | res = filter_rcv(sk, buf); |
| 1324 | } else { | 1324 | } else { |
| 1325 | sk_add_backlog(sk, buf); | 1325 | if (sk_add_backlog(sk, buf)) |
| 1326 | res = TIPC_OK; | 1326 | res = TIPC_ERR_OVERLOAD; |
| 1327 | else | ||
| 1328 | res = TIPC_OK; | ||
| 1327 | } | 1329 | } |
| 1328 | bh_unlock_sock(sk); | 1330 | bh_unlock_sock(sk); |
| 1329 | 1331 | ||
| @@ -1341,8 +1343,8 @@ static void wakeupdispatch(struct tipc_port *tport) | |||
| 1341 | { | 1343 | { |
| 1342 | struct sock *sk = (struct sock *)tport->usr_handle; | 1344 | struct sock *sk = (struct sock *)tport->usr_handle; |
| 1343 | 1345 | ||
| 1344 | if (waitqueue_active(sk->sk_sleep)) | 1346 | if (waitqueue_active(sk_sleep(sk))) |
| 1345 | wake_up_interruptible(sk->sk_sleep); | 1347 | wake_up_interruptible(sk_sleep(sk)); |
| 1346 | } | 1348 | } |
| 1347 | 1349 | ||
| 1348 | /** | 1350 | /** |
| @@ -1424,7 +1426,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen, | |||
| 1424 | /* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */ | 1426 | /* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */ |
| 1425 | 1427 | ||
| 1426 | release_sock(sk); | 1428 | release_sock(sk); |
| 1427 | res = wait_event_interruptible_timeout(*sk->sk_sleep, | 1429 | res = wait_event_interruptible_timeout(*sk_sleep(sk), |
| 1428 | (!skb_queue_empty(&sk->sk_receive_queue) || | 1430 | (!skb_queue_empty(&sk->sk_receive_queue) || |
| 1429 | (sock->state != SS_CONNECTING)), | 1431 | (sock->state != SS_CONNECTING)), |
| 1430 | sk->sk_rcvtimeo); | 1432 | sk->sk_rcvtimeo); |
| @@ -1519,7 +1521,7 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags) | |||
| 1519 | goto exit; | 1521 | goto exit; |
| 1520 | } | 1522 | } |
| 1521 | release_sock(sk); | 1523 | release_sock(sk); |
| 1522 | res = wait_event_interruptible(*sk->sk_sleep, | 1524 | res = wait_event_interruptible(*sk_sleep(sk), |
| 1523 | (!skb_queue_empty(&sk->sk_receive_queue))); | 1525 | (!skb_queue_empty(&sk->sk_receive_queue))); |
| 1524 | lock_sock(sk); | 1526 | lock_sock(sk); |
| 1525 | if (res) | 1527 | if (res) |
| @@ -1630,8 +1632,8 @@ restart: | |||
| 1630 | /* Discard any unreceived messages; wake up sleeping tasks */ | 1632 | /* Discard any unreceived messages; wake up sleeping tasks */ |
| 1631 | 1633 | ||
| 1632 | discard_rx_queue(sk); | 1634 | discard_rx_queue(sk); |
| 1633 | if (waitqueue_active(sk->sk_sleep)) | 1635 | if (waitqueue_active(sk_sleep(sk))) |
| 1634 | wake_up_interruptible(sk->sk_sleep); | 1636 | wake_up_interruptible(sk_sleep(sk)); |
| 1635 | res = 0; | 1637 | res = 0; |
| 1636 | break; | 1638 | break; |
| 1637 | 1639 | ||
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index ac91f0dfa144..ab6eab4c45e2 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
| @@ -76,19 +76,6 @@ struct top_srv { | |||
| 76 | static struct top_srv topsrv = { 0 }; | 76 | static struct top_srv topsrv = { 0 }; |
| 77 | 77 | ||
| 78 | /** | 78 | /** |
| 79 | * htohl - convert value to endianness used by destination | ||
| 80 | * @in: value to convert | ||
| 81 | * @swap: non-zero if endianness must be reversed | ||
| 82 | * | ||
| 83 | * Returns converted value | ||
| 84 | */ | ||
| 85 | |||
| 86 | static u32 htohl(u32 in, int swap) | ||
| 87 | { | ||
| 88 | return swap ? swab32(in) : in; | ||
| 89 | } | ||
| 90 | |||
| 91 | /** | ||
| 92 | * subscr_send_event - send a message containing a tipc_event to the subscriber | 79 | * subscr_send_event - send a message containing a tipc_event to the subscriber |
| 93 | * | 80 | * |
| 94 | * Note: Must not hold subscriber's server port lock, since tipc_send() will | 81 | * Note: Must not hold subscriber's server port lock, since tipc_send() will |
| @@ -107,11 +94,11 @@ static void subscr_send_event(struct subscription *sub, | |||
| 107 | msg_sect.iov_base = (void *)&sub->evt; | 94 | msg_sect.iov_base = (void *)&sub->evt; |
| 108 | msg_sect.iov_len = sizeof(struct tipc_event); | 95 | msg_sect.iov_len = sizeof(struct tipc_event); |
| 109 | 96 | ||
| 110 | sub->evt.event = htohl(event, sub->swap); | 97 | sub->evt.event = htonl(event); |
| 111 | sub->evt.found_lower = htohl(found_lower, sub->swap); | 98 | sub->evt.found_lower = htonl(found_lower); |
| 112 | sub->evt.found_upper = htohl(found_upper, sub->swap); | 99 | sub->evt.found_upper = htonl(found_upper); |
| 113 | sub->evt.port.ref = htohl(port_ref, sub->swap); | 100 | sub->evt.port.ref = htonl(port_ref); |
| 114 | sub->evt.port.node = htohl(node, sub->swap); | 101 | sub->evt.port.node = htonl(node); |
| 115 | tipc_send(sub->server_ref, 1, &msg_sect); | 102 | tipc_send(sub->server_ref, 1, &msg_sect); |
| 116 | } | 103 | } |
| 117 | 104 | ||
| @@ -287,16 +274,29 @@ static void subscr_cancel(struct tipc_subscr *s, | |||
| 287 | { | 274 | { |
| 288 | struct subscription *sub; | 275 | struct subscription *sub; |
| 289 | struct subscription *sub_temp; | 276 | struct subscription *sub_temp; |
| 277 | __u32 type, lower, upper, timeout, filter; | ||
| 290 | int found = 0; | 278 | int found = 0; |
| 291 | 279 | ||
| 292 | /* Find first matching subscription, exit if not found */ | 280 | /* Find first matching subscription, exit if not found */ |
| 293 | 281 | ||
| 282 | type = ntohl(s->seq.type); | ||
| 283 | lower = ntohl(s->seq.lower); | ||
| 284 | upper = ntohl(s->seq.upper); | ||
| 285 | timeout = ntohl(s->timeout); | ||
| 286 | filter = ntohl(s->filter) & ~TIPC_SUB_CANCEL; | ||
| 287 | |||
| 294 | list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, | 288 | list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, |
| 295 | subscription_list) { | 289 | subscription_list) { |
| 296 | if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) { | 290 | if ((type == sub->seq.type) && |
| 297 | found = 1; | 291 | (lower == sub->seq.lower) && |
| 298 | break; | 292 | (upper == sub->seq.upper) && |
| 299 | } | 293 | (timeout == sub->timeout) && |
| 294 | (filter == sub->filter) && | ||
| 295 | !memcmp(s->usr_handle,sub->evt.s.usr_handle, | ||
| 296 | sizeof(s->usr_handle)) ){ | ||
| 297 | found = 1; | ||
| 298 | break; | ||
| 299 | } | ||
| 300 | } | 300 | } |
| 301 | if (!found) | 301 | if (!found) |
| 302 | return; | 302 | return; |
| @@ -310,7 +310,7 @@ static void subscr_cancel(struct tipc_subscr *s, | |||
| 310 | k_term_timer(&sub->timer); | 310 | k_term_timer(&sub->timer); |
| 311 | spin_lock_bh(subscriber->lock); | 311 | spin_lock_bh(subscriber->lock); |
| 312 | } | 312 | } |
| 313 | dbg("Cancel: removing sub %u,%u,%u from subscriber %x list\n", | 313 | dbg("Cancel: removing sub %u,%u,%u from subscriber %p list\n", |
| 314 | sub->seq.type, sub->seq.lower, sub->seq.upper, subscriber); | 314 | sub->seq.type, sub->seq.lower, sub->seq.upper, subscriber); |
| 315 | subscr_del(sub); | 315 | subscr_del(sub); |
| 316 | } | 316 | } |
| @@ -325,16 +325,10 @@ static struct subscription *subscr_subscribe(struct tipc_subscr *s, | |||
| 325 | struct subscriber *subscriber) | 325 | struct subscriber *subscriber) |
| 326 | { | 326 | { |
| 327 | struct subscription *sub; | 327 | struct subscription *sub; |
| 328 | int swap; | ||
| 329 | |||
| 330 | /* Determine subscriber's endianness */ | ||
| 331 | |||
| 332 | swap = !(s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE)); | ||
| 333 | 328 | ||
| 334 | /* Detect & process a subscription cancellation request */ | 329 | /* Detect & process a subscription cancellation request */ |
| 335 | 330 | ||
| 336 | if (s->filter & htohl(TIPC_SUB_CANCEL, swap)) { | 331 | if (ntohl(s->filter) & TIPC_SUB_CANCEL) { |
| 337 | s->filter &= ~htohl(TIPC_SUB_CANCEL, swap); | ||
| 338 | subscr_cancel(s, subscriber); | 332 | subscr_cancel(s, subscriber); |
| 339 | return NULL; | 333 | return NULL; |
| 340 | } | 334 | } |
| @@ -359,13 +353,12 @@ static struct subscription *subscr_subscribe(struct tipc_subscr *s, | |||
| 359 | 353 | ||
| 360 | /* Initialize subscription object */ | 354 | /* Initialize subscription object */ |
| 361 | 355 | ||
| 362 | sub->seq.type = htohl(s->seq.type, swap); | 356 | sub->seq.type = ntohl(s->seq.type); |
| 363 | sub->seq.lower = htohl(s->seq.lower, swap); | 357 | sub->seq.lower = ntohl(s->seq.lower); |
| 364 | sub->seq.upper = htohl(s->seq.upper, swap); | 358 | sub->seq.upper = ntohl(s->seq.upper); |
| 365 | sub->timeout = htohl(s->timeout, swap); | 359 | sub->timeout = ntohl(s->timeout); |
| 366 | sub->filter = htohl(s->filter, swap); | 360 | sub->filter = ntohl(s->filter); |
| 367 | if ((!(sub->filter & TIPC_SUB_PORTS) == | 361 | if ((sub->filter && (sub->filter != TIPC_SUB_PORTS)) || |
| 368 | !(sub->filter & TIPC_SUB_SERVICE)) || | ||
| 369 | (sub->seq.lower > sub->seq.upper)) { | 362 | (sub->seq.lower > sub->seq.upper)) { |
| 370 | warn("Subscription rejected, illegal request\n"); | 363 | warn("Subscription rejected, illegal request\n"); |
| 371 | kfree(sub); | 364 | kfree(sub); |
| @@ -376,7 +369,6 @@ static struct subscription *subscr_subscribe(struct tipc_subscr *s, | |||
| 376 | INIT_LIST_HEAD(&sub->nameseq_list); | 369 | INIT_LIST_HEAD(&sub->nameseq_list); |
| 377 | list_add(&sub->subscription_list, &subscriber->subscription_list); | 370 | list_add(&sub->subscription_list, &subscriber->subscription_list); |
| 378 | sub->server_ref = subscriber->port_ref; | 371 | sub->server_ref = subscriber->port_ref; |
| 379 | sub->swap = swap; | ||
| 380 | memcpy(&sub->evt.s, s, sizeof(struct tipc_subscr)); | 372 | memcpy(&sub->evt.s, s, sizeof(struct tipc_subscr)); |
| 381 | atomic_inc(&topsrv.subscription_count); | 373 | atomic_inc(&topsrv.subscription_count); |
| 382 | if (sub->timeout != TIPC_WAIT_FOREVER) { | 374 | if (sub->timeout != TIPC_WAIT_FOREVER) { |
diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h index 45d89bf4d202..c20f496d95b2 100644 --- a/net/tipc/subscr.h +++ b/net/tipc/subscr.h | |||
| @@ -53,7 +53,6 @@ typedef void (*tipc_subscr_event) (struct subscription *sub, | |||
| 53 | * @nameseq_list: adjacent subscriptions in name sequence's subscription list | 53 | * @nameseq_list: adjacent subscriptions in name sequence's subscription list |
| 54 | * @subscription_list: adjacent subscriptions in subscriber's subscription list | 54 | * @subscription_list: adjacent subscriptions in subscriber's subscription list |
| 55 | * @server_ref: object reference of server port associated with subscription | 55 | * @server_ref: object reference of server port associated with subscription |
| 56 | * @swap: indicates if subscriber uses opposite endianness in its messages | ||
| 57 | * @evt: template for events generated by subscription | 56 | * @evt: template for events generated by subscription |
| 58 | */ | 57 | */ |
| 59 | 58 | ||
| @@ -66,7 +65,6 @@ struct subscription { | |||
| 66 | struct list_head nameseq_list; | 65 | struct list_head nameseq_list; |
| 67 | struct list_head subscription_list; | 66 | struct list_head subscription_list; |
| 68 | u32 server_ref; | 67 | u32 server_ref; |
| 69 | int swap; | ||
| 70 | struct tipc_event evt; | 68 | struct tipc_event evt; |
| 71 | }; | 69 | }; |
| 72 | 70 | ||
