diff options
| author | David S. Miller <davem@davemloft.net> | 2013-10-18 13:22:19 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2013-10-18 13:22:19 -0400 |
| commit | ace0d5d8bf8a69866e4394ca2e4c5d1296ef7db2 (patch) | |
| tree | d12bae2180f77b4dc48580bf5a85b995f1f4909c /net/tipc/port.c | |
| parent | 7cc7c5e54b7128195a1403747a63971c3c3f8e25 (diff) | |
| parent | bbfbe47cc99ce093708aaf28b7f2c08d28045c67 (diff) | |
Merge branch 'tipc'
Jon Maloy says:
====================
Some small and relatively straightforward patches. With exception of
the two first ones they are all unrelated and address minor issues.
v2: update of v1 (http://patchwork.ozlabs.org/patch/277404/)
-added commit to use memcpy_fromiovec on user data as per v1 feedback
-updated sparse fix commit to drop chunks covered by above commit
-added new commit that greatly simplifies the link lookup routine
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/port.c')
| -rw-r--r-- | net/tipc/port.c | 66 |
1 files changed, 27 insertions, 39 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c index b3ed2fcab4fb..c081a7632302 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c | |||
| @@ -90,8 +90,7 @@ int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg) | |||
| 90 | * tipc_multicast - send a multicast message to local and remote destinations | 90 | * tipc_multicast - send a multicast message to local and remote destinations |
| 91 | */ | 91 | */ |
| 92 | int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, | 92 | int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, |
| 93 | u32 num_sect, struct iovec const *msg_sect, | 93 | struct iovec const *msg_sect, unsigned int len) |
| 94 | unsigned int total_len) | ||
| 95 | { | 94 | { |
| 96 | struct tipc_msg *hdr; | 95 | struct tipc_msg *hdr; |
| 97 | struct sk_buff *buf; | 96 | struct sk_buff *buf; |
| @@ -114,8 +113,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, | |||
| 114 | msg_set_namelower(hdr, seq->lower); | 113 | msg_set_namelower(hdr, seq->lower); |
| 115 | msg_set_nameupper(hdr, seq->upper); | 114 | msg_set_nameupper(hdr, seq->upper); |
| 116 | msg_set_hdr_sz(hdr, MCAST_H_SIZE); | 115 | msg_set_hdr_sz(hdr, MCAST_H_SIZE); |
| 117 | res = tipc_msg_build(hdr, msg_sect, num_sect, total_len, MAX_MSG_SIZE, | 116 | res = tipc_msg_build(hdr, msg_sect, len, MAX_MSG_SIZE, &buf); |
| 118 | &buf); | ||
| 119 | if (unlikely(!buf)) | 117 | if (unlikely(!buf)) |
| 120 | return res; | 118 | return res; |
| 121 | 119 | ||
| @@ -436,14 +434,13 @@ exit: | |||
| 436 | } | 434 | } |
| 437 | 435 | ||
| 438 | int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr, | 436 | int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr, |
| 439 | struct iovec const *msg_sect, u32 num_sect, | 437 | struct iovec const *msg_sect, unsigned int len, |
| 440 | unsigned int total_len, int err) | 438 | int err) |
| 441 | { | 439 | { |
| 442 | struct sk_buff *buf; | 440 | struct sk_buff *buf; |
| 443 | int res; | 441 | int res; |
| 444 | 442 | ||
| 445 | res = tipc_msg_build(hdr, msg_sect, num_sect, total_len, MAX_MSG_SIZE, | 443 | res = tipc_msg_build(hdr, msg_sect, len, MAX_MSG_SIZE, &buf); |
| 446 | &buf); | ||
| 447 | if (!buf) | 444 | if (!buf) |
| 448 | return res; | 445 | return res; |
| 449 | 446 | ||
| @@ -918,15 +915,14 @@ int tipc_port_recv_msg(struct sk_buff *buf) | |||
| 918 | * tipc_port_recv_sections(): Concatenate and deliver sectioned | 915 | * tipc_port_recv_sections(): Concatenate and deliver sectioned |
| 919 | * message for this node. | 916 | * message for this node. |
| 920 | */ | 917 | */ |
| 921 | static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_sect, | 918 | static int tipc_port_recv_sections(struct tipc_port *sender, |
| 922 | struct iovec const *msg_sect, | 919 | struct iovec const *msg_sect, |
| 923 | unsigned int total_len) | 920 | unsigned int len) |
| 924 | { | 921 | { |
| 925 | struct sk_buff *buf; | 922 | struct sk_buff *buf; |
| 926 | int res; | 923 | int res; |
| 927 | 924 | ||
| 928 | res = tipc_msg_build(&sender->phdr, msg_sect, num_sect, total_len, | 925 | res = tipc_msg_build(&sender->phdr, msg_sect, len, MAX_MSG_SIZE, &buf); |
| 929 | MAX_MSG_SIZE, &buf); | ||
| 930 | if (likely(buf)) | 926 | if (likely(buf)) |
| 931 | tipc_port_recv_msg(buf); | 927 | tipc_port_recv_msg(buf); |
| 932 | return res; | 928 | return res; |
| @@ -935,8 +931,7 @@ static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_se | |||
| 935 | /** | 931 | /** |
| 936 | * tipc_send - send message sections on connection | 932 | * tipc_send - send message sections on connection |
| 937 | */ | 933 | */ |
| 938 | int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, | 934 | int tipc_send(u32 ref, struct iovec const *msg_sect, unsigned int len) |
| 939 | unsigned int total_len) | ||
| 940 | { | 935 | { |
| 941 | struct tipc_port *p_ptr; | 936 | struct tipc_port *p_ptr; |
| 942 | u32 destnode; | 937 | u32 destnode; |
| @@ -950,11 +945,10 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, | |||
| 950 | if (!tipc_port_congested(p_ptr)) { | 945 | if (!tipc_port_congested(p_ptr)) { |
| 951 | destnode = port_peernode(p_ptr); | 946 | destnode = port_peernode(p_ptr); |
| 952 | if (likely(!in_own_node(destnode))) | 947 | if (likely(!in_own_node(destnode))) |
| 953 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, | 948 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, |
| 954 | total_len, destnode); | 949 | len, destnode); |
| 955 | else | 950 | else |
| 956 | res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect, | 951 | res = tipc_port_recv_sections(p_ptr, msg_sect, len); |
| 957 | total_len); | ||
| 958 | 952 | ||
| 959 | if (likely(res != -ELINKCONG)) { | 953 | if (likely(res != -ELINKCONG)) { |
| 960 | p_ptr->congested = 0; | 954 | p_ptr->congested = 0; |
| @@ -965,7 +959,7 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, | |||
| 965 | } | 959 | } |
| 966 | if (port_unreliable(p_ptr)) { | 960 | if (port_unreliable(p_ptr)) { |
| 967 | p_ptr->congested = 0; | 961 | p_ptr->congested = 0; |
| 968 | return total_len; | 962 | return len; |
| 969 | } | 963 | } |
| 970 | return -ELINKCONG; | 964 | return -ELINKCONG; |
| 971 | } | 965 | } |
| @@ -974,8 +968,7 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, | |||
| 974 | * tipc_send2name - send message sections to port name | 968 | * tipc_send2name - send message sections to port name |
| 975 | */ | 969 | */ |
| 976 | int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, | 970 | int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, |
| 977 | unsigned int num_sect, struct iovec const *msg_sect, | 971 | struct iovec const *msg_sect, unsigned int len) |
| 978 | unsigned int total_len) | ||
| 979 | { | 972 | { |
| 980 | struct tipc_port *p_ptr; | 973 | struct tipc_port *p_ptr; |
| 981 | struct tipc_msg *msg; | 974 | struct tipc_msg *msg; |
| @@ -999,36 +992,32 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, | |||
| 999 | 992 | ||
| 1000 | if (likely(destport || destnode)) { | 993 | if (likely(destport || destnode)) { |
| 1001 | if (likely(in_own_node(destnode))) | 994 | if (likely(in_own_node(destnode))) |
| 1002 | res = tipc_port_recv_sections(p_ptr, num_sect, | 995 | res = tipc_port_recv_sections(p_ptr, msg_sect, len); |
| 1003 | msg_sect, total_len); | ||
| 1004 | else if (tipc_own_addr) | 996 | else if (tipc_own_addr) |
| 1005 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, | 997 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, |
| 1006 | num_sect, total_len, | 998 | len, destnode); |
| 1007 | destnode); | ||
| 1008 | else | 999 | else |
| 1009 | res = tipc_port_reject_sections(p_ptr, msg, msg_sect, | 1000 | res = tipc_port_reject_sections(p_ptr, msg, msg_sect, |
| 1010 | num_sect, total_len, | 1001 | len, TIPC_ERR_NO_NODE); |
| 1011 | TIPC_ERR_NO_NODE); | ||
| 1012 | if (likely(res != -ELINKCONG)) { | 1002 | if (likely(res != -ELINKCONG)) { |
| 1013 | if (res > 0) | 1003 | if (res > 0) |
| 1014 | p_ptr->sent++; | 1004 | p_ptr->sent++; |
| 1015 | return res; | 1005 | return res; |
| 1016 | } | 1006 | } |
| 1017 | if (port_unreliable(p_ptr)) { | 1007 | if (port_unreliable(p_ptr)) { |
| 1018 | return total_len; | 1008 | return len; |
| 1019 | } | 1009 | } |
| 1020 | return -ELINKCONG; | 1010 | return -ELINKCONG; |
| 1021 | } | 1011 | } |
| 1022 | return tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect, | 1012 | return tipc_port_reject_sections(p_ptr, msg, msg_sect, len, |
| 1023 | total_len, TIPC_ERR_NO_NAME); | 1013 | TIPC_ERR_NO_NAME); |
| 1024 | } | 1014 | } |
| 1025 | 1015 | ||
| 1026 | /** | 1016 | /** |
| 1027 | * tipc_send2port - send message sections to port identity | 1017 | * tipc_send2port - send message sections to port identity |
| 1028 | */ | 1018 | */ |
| 1029 | int tipc_send2port(u32 ref, struct tipc_portid const *dest, | 1019 | int tipc_send2port(u32 ref, struct tipc_portid const *dest, |
| 1030 | unsigned int num_sect, struct iovec const *msg_sect, | 1020 | struct iovec const *msg_sect, unsigned int len) |
| 1031 | unsigned int total_len) | ||
| 1032 | { | 1021 | { |
| 1033 | struct tipc_port *p_ptr; | 1022 | struct tipc_port *p_ptr; |
| 1034 | struct tipc_msg *msg; | 1023 | struct tipc_msg *msg; |
| @@ -1046,21 +1035,20 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest, | |||
| 1046 | msg_set_hdr_sz(msg, BASIC_H_SIZE); | 1035 | msg_set_hdr_sz(msg, BASIC_H_SIZE); |
| 1047 | 1036 | ||
| 1048 | if (in_own_node(dest->node)) | 1037 | if (in_own_node(dest->node)) |
| 1049 | res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect, | 1038 | res = tipc_port_recv_sections(p_ptr, msg_sect, len); |
| 1050 | total_len); | ||
| 1051 | else if (tipc_own_addr) | 1039 | else if (tipc_own_addr) |
| 1052 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, | 1040 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, len, |
| 1053 | total_len, dest->node); | 1041 | dest->node); |
| 1054 | else | 1042 | else |
| 1055 | res = tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect, | 1043 | res = tipc_port_reject_sections(p_ptr, msg, msg_sect, len, |
| 1056 | total_len, TIPC_ERR_NO_NODE); | 1044 | TIPC_ERR_NO_NODE); |
| 1057 | if (likely(res != -ELINKCONG)) { | 1045 | if (likely(res != -ELINKCONG)) { |
| 1058 | if (res > 0) | 1046 | if (res > 0) |
| 1059 | p_ptr->sent++; | 1047 | p_ptr->sent++; |
| 1060 | return res; | 1048 | return res; |
| 1061 | } | 1049 | } |
| 1062 | if (port_unreliable(p_ptr)) { | 1050 | if (port_unreliable(p_ptr)) { |
| 1063 | return total_len; | 1051 | return len; |
| 1064 | } | 1052 | } |
| 1065 | return -ELINKCONG; | 1053 | return -ELINKCONG; |
| 1066 | } | 1054 | } |
