diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2006-11-17 07:57:30 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-03 00:23:53 -0500 |
commit | 7174259e6ced15bebee202983511d8fc950e929f (patch) | |
tree | 1aedc8d33972397bd6cfc8f99804e3a6b7f597c0 /net | |
parent | 32aac18dfa0963fde40cc074ba97ebbae8b755f2 (diff) |
[TCP_IPV4]: CodingStyle cleanups, no code change
Mostly related to CONFIG_TCP_MD5SIG recent merge.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 143 |
1 files changed, 75 insertions, 68 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index dadf80272413..010dff442a11 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -93,16 +93,18 @@ static struct socket *tcp_socket; | |||
93 | void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb); | 93 | void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb); |
94 | 94 | ||
95 | #ifdef CONFIG_TCP_MD5SIG | 95 | #ifdef CONFIG_TCP_MD5SIG |
96 | static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr); | 96 | static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, |
97 | __be32 addr); | ||
97 | static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, | 98 | static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, |
98 | __be32 saddr, __be32 daddr, struct tcphdr *th, | 99 | __be32 saddr, __be32 daddr, |
99 | int protocol, int tcplen); | 100 | struct tcphdr *th, int protocol, |
101 | int tcplen); | ||
100 | #endif | 102 | #endif |
101 | 103 | ||
102 | struct inet_hashinfo __cacheline_aligned tcp_hashinfo = { | 104 | struct inet_hashinfo __cacheline_aligned tcp_hashinfo = { |
103 | .lhash_lock = __RW_LOCK_UNLOCKED(tcp_hashinfo.lhash_lock), | 105 | .lhash_lock = __RW_LOCK_UNLOCKED(tcp_hashinfo.lhash_lock), |
104 | .lhash_users = ATOMIC_INIT(0), | 106 | .lhash_users = ATOMIC_INIT(0), |
105 | .lhash_wait = __WAIT_QUEUE_HEAD_INITIALIZER(tcp_hashinfo.lhash_wait), | 107 | .lhash_wait = __WAIT_QUEUE_HEAD_INITIALIZER(tcp_hashinfo.lhash_wait), |
106 | }; | 108 | }; |
107 | 109 | ||
108 | static int tcp_v4_get_port(struct sock *sk, unsigned short snum) | 110 | static int tcp_v4_get_port(struct sock *sk, unsigned short snum) |
@@ -215,13 +217,14 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
215 | if (tcp_death_row.sysctl_tw_recycle && | 217 | if (tcp_death_row.sysctl_tw_recycle && |
216 | !tp->rx_opt.ts_recent_stamp && rt->rt_dst == daddr) { | 218 | !tp->rx_opt.ts_recent_stamp && rt->rt_dst == daddr) { |
217 | struct inet_peer *peer = rt_get_peer(rt); | 219 | struct inet_peer *peer = rt_get_peer(rt); |
218 | 220 | /* | |
219 | /* VJ's idea. We save last timestamp seen from | 221 | * VJ's idea. We save last timestamp seen from |
220 | * the destination in peer table, when entering state TIME-WAIT | 222 | * the destination in peer table, when entering state |
221 | * and initialize rx_opt.ts_recent from it, when trying new connection. | 223 | * TIME-WAIT * and initialize rx_opt.ts_recent from it, |
224 | * when trying new connection. | ||
222 | */ | 225 | */ |
223 | 226 | if (peer != NULL && | |
224 | if (peer && peer->tcp_ts_stamp + TCP_PAWS_MSL >= xtime.tv_sec) { | 227 | peer->tcp_ts_stamp + TCP_PAWS_MSL >= xtime.tv_sec) { |
225 | tp->rx_opt.ts_recent_stamp = peer->tcp_ts_stamp; | 228 | tp->rx_opt.ts_recent_stamp = peer->tcp_ts_stamp; |
226 | tp->rx_opt.ts_recent = peer->tcp_ts; | 229 | tp->rx_opt.ts_recent = peer->tcp_ts; |
227 | } | 230 | } |
@@ -246,7 +249,8 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
246 | if (err) | 249 | if (err) |
247 | goto failure; | 250 | goto failure; |
248 | 251 | ||
249 | err = ip_route_newports(&rt, IPPROTO_TCP, inet->sport, inet->dport, sk); | 252 | err = ip_route_newports(&rt, IPPROTO_TCP, |
253 | inet->sport, inet->dport, sk); | ||
250 | if (err) | 254 | if (err) |
251 | goto failure; | 255 | goto failure; |
252 | 256 | ||
@@ -270,7 +274,10 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
270 | return 0; | 274 | return 0; |
271 | 275 | ||
272 | failure: | 276 | failure: |
273 | /* This unhashes the socket and releases the local port, if necessary. */ | 277 | /* |
278 | * This unhashes the socket and releases the local port, | ||
279 | * if necessary. | ||
280 | */ | ||
274 | tcp_set_state(sk, TCP_CLOSE); | 281 | tcp_set_state(sk, TCP_CLOSE); |
275 | ip_rt_put(rt); | 282 | ip_rt_put(rt); |
276 | sk->sk_route_caps = 0; | 283 | sk->sk_route_caps = 0; |
@@ -495,7 +502,8 @@ void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb) | |||
495 | struct tcphdr *th = skb->h.th; | 502 | struct tcphdr *th = skb->h.th; |
496 | 503 | ||
497 | if (skb->ip_summed == CHECKSUM_PARTIAL) { | 504 | if (skb->ip_summed == CHECKSUM_PARTIAL) { |
498 | th->check = ~tcp_v4_check(th, len, inet->saddr, inet->daddr, 0); | 505 | th->check = ~tcp_v4_check(th, len, |
506 | inet->saddr, inet->daddr, 0); | ||
499 | skb->csum = offsetof(struct tcphdr, check); | 507 | skb->csum = offsetof(struct tcphdr, check); |
500 | } else { | 508 | } else { |
501 | th->check = tcp_v4_check(th, len, inet->saddr, inet->daddr, | 509 | th->check = tcp_v4_check(th, len, inet->saddr, inet->daddr, |
@@ -572,7 +580,7 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) | |||
572 | skb->len - (th->doff << 2)); | 580 | skb->len - (th->doff << 2)); |
573 | } | 581 | } |
574 | 582 | ||
575 | memset(&arg, 0, sizeof arg); | 583 | memset(&arg, 0, sizeof(arg)); |
576 | arg.iov[0].iov_base = (unsigned char *)&rep; | 584 | arg.iov[0].iov_base = (unsigned char *)&rep; |
577 | arg.iov[0].iov_len = sizeof(rep.th); | 585 | arg.iov[0].iov_len = sizeof(rep.th); |
578 | 586 | ||
@@ -595,9 +603,8 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) | |||
595 | arg.iov[0].iov_len); | 603 | arg.iov[0].iov_len); |
596 | } | 604 | } |
597 | #endif | 605 | #endif |
598 | |||
599 | arg.csum = csum_tcpudp_nofold(skb->nh.iph->daddr, | 606 | arg.csum = csum_tcpudp_nofold(skb->nh.iph->daddr, |
600 | skb->nh.iph->saddr, /*XXX*/ | 607 | skb->nh.iph->saddr, /* XXX */ |
601 | sizeof(struct tcphdr), IPPROTO_TCP, 0); | 608 | sizeof(struct tcphdr), IPPROTO_TCP, 0); |
602 | arg.csumoffset = offsetof(struct tcphdr, check) / 2; | 609 | arg.csumoffset = offsetof(struct tcphdr, check) / 2; |
603 | 610 | ||
@@ -631,7 +638,7 @@ static void tcp_v4_send_ack(struct tcp_timewait_sock *twsk, | |||
631 | #endif | 638 | #endif |
632 | 639 | ||
633 | memset(&rep.th, 0, sizeof(struct tcphdr)); | 640 | memset(&rep.th, 0, sizeof(struct tcphdr)); |
634 | memset(&arg, 0, sizeof arg); | 641 | memset(&arg, 0, sizeof(arg)); |
635 | 642 | ||
636 | arg.iov[0].iov_base = (unsigned char *)&rep; | 643 | arg.iov[0].iov_base = (unsigned char *)&rep; |
637 | arg.iov[0].iov_len = sizeof(rep.th); | 644 | arg.iov[0].iov_len = sizeof(rep.th); |
@@ -668,9 +675,8 @@ static void tcp_v4_send_ack(struct tcp_timewait_sock *twsk, | |||
668 | tw_key.key = twsk->tw_md5_key; | 675 | tw_key.key = twsk->tw_md5_key; |
669 | tw_key.keylen = twsk->tw_md5_keylen; | 676 | tw_key.keylen = twsk->tw_md5_keylen; |
670 | key = &tw_key; | 677 | key = &tw_key; |
671 | } else { | 678 | } else |
672 | key = NULL; | 679 | key = NULL; |
673 | } | ||
674 | 680 | ||
675 | if (key) { | 681 | if (key) { |
676 | int offset = (ts) ? 3 : 0; | 682 | int offset = (ts) ? 3 : 0; |
@@ -690,9 +696,8 @@ static void tcp_v4_send_ack(struct tcp_timewait_sock *twsk, | |||
690 | arg.iov[0].iov_len); | 696 | arg.iov[0].iov_len); |
691 | } | 697 | } |
692 | #endif | 698 | #endif |
693 | |||
694 | arg.csum = csum_tcpudp_nofold(skb->nh.iph->daddr, | 699 | arg.csum = csum_tcpudp_nofold(skb->nh.iph->daddr, |
695 | skb->nh.iph->saddr, /*XXX*/ | 700 | skb->nh.iph->saddr, /* XXX */ |
696 | arg.iov[0].iov_len, IPPROTO_TCP, 0); | 701 | arg.iov[0].iov_len, IPPROTO_TCP, 0); |
697 | arg.csumoffset = offsetof(struct tcphdr, check) / 2; | 702 | arg.csumoffset = offsetof(struct tcphdr, check) / 2; |
698 | 703 | ||
@@ -707,12 +712,14 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb) | |||
707 | struct tcp_timewait_sock *tcptw = tcp_twsk(sk); | 712 | struct tcp_timewait_sock *tcptw = tcp_twsk(sk); |
708 | 713 | ||
709 | tcp_v4_send_ack(tcptw, skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt, | 714 | tcp_v4_send_ack(tcptw, skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt, |
710 | tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale, tcptw->tw_ts_recent); | 715 | tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale, |
716 | tcptw->tw_ts_recent); | ||
711 | 717 | ||
712 | inet_twsk_put(tw); | 718 | inet_twsk_put(tw); |
713 | } | 719 | } |
714 | 720 | ||
715 | static void tcp_v4_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req) | 721 | static void tcp_v4_reqsk_send_ack(struct sk_buff *skb, |
722 | struct request_sock *req) | ||
716 | { | 723 | { |
717 | tcp_v4_send_ack(NULL, skb, tcp_rsk(req)->snt_isn + 1, | 724 | tcp_v4_send_ack(NULL, skb, tcp_rsk(req)->snt_isn + 1, |
718 | tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, | 725 | tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, |
@@ -809,7 +816,8 @@ static struct ip_options *tcp_v4_save_options(struct sock *sk, | |||
809 | */ | 816 | */ |
810 | 817 | ||
811 | /* Find the Key structure for an address. */ | 818 | /* Find the Key structure for an address. */ |
812 | static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr) | 819 | static struct tcp_md5sig_key * |
820 | tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr) | ||
813 | { | 821 | { |
814 | struct tcp_sock *tp = tcp_sk(sk); | 822 | struct tcp_sock *tp = tcp_sk(sk); |
815 | int i; | 823 | int i; |
@@ -818,7 +826,8 @@ static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr) | |||
818 | return NULL; | 826 | return NULL; |
819 | for (i = 0; i < tp->md5sig_info->entries4; i++) { | 827 | for (i = 0; i < tp->md5sig_info->entries4; i++) { |
820 | if (tp->md5sig_info->keys4[i].addr == addr) | 828 | if (tp->md5sig_info->keys4[i].addr == addr) |
821 | return (struct tcp_md5sig_key *)&tp->md5sig_info->keys4[i]; | 829 | return (struct tcp_md5sig_key *) |
830 | &tp->md5sig_info->keys4[i]; | ||
822 | } | 831 | } |
823 | return NULL; | 832 | return NULL; |
824 | } | 833 | } |
@@ -915,13 +924,12 @@ int tcp_v4_md5_do_del(struct sock *sk, __be32 addr) | |||
915 | if (tp->md5sig_info->entries4 == 0) { | 924 | if (tp->md5sig_info->entries4 == 0) { |
916 | kfree(tp->md5sig_info->keys4); | 925 | kfree(tp->md5sig_info->keys4); |
917 | tp->md5sig_info->keys4 = NULL; | 926 | tp->md5sig_info->keys4 = NULL; |
918 | } else { | 927 | } else if (tp->md5sig_info->entries4 != i) { |
919 | /* Need to do some manipulation */ | 928 | /* Need to do some manipulation */ |
920 | if (tp->md5sig_info->entries4 != i) | 929 | memcpy(&tp->md5sig_info->keys4[i], |
921 | memcpy(&tp->md5sig_info->keys4[i], | 930 | &tp->md5sig_info->keys4[i+1], |
922 | &tp->md5sig_info->keys4[i+1], | 931 | (tp->md5sig_info->entries4 - i) * |
923 | (tp->md5sig_info->entries4 - i) | 932 | sizeof(struct tcp4_md5sig_key)); |
924 | * sizeof (struct tcp4_md5sig_key)); | ||
925 | } | 933 | } |
926 | tcp_free_md5sig_pool(); | 934 | tcp_free_md5sig_pool(); |
927 | return 0; | 935 | return 0; |
@@ -932,7 +940,7 @@ int tcp_v4_md5_do_del(struct sock *sk, __be32 addr) | |||
932 | 940 | ||
933 | EXPORT_SYMBOL(tcp_v4_md5_do_del); | 941 | EXPORT_SYMBOL(tcp_v4_md5_do_del); |
934 | 942 | ||
935 | static void tcp_v4_clear_md5_list (struct sock *sk) | 943 | static void tcp_v4_clear_md5_list(struct sock *sk) |
936 | { | 944 | { |
937 | struct tcp_sock *tp = tcp_sk(sk); | 945 | struct tcp_sock *tp = tcp_sk(sk); |
938 | 946 | ||
@@ -954,8 +962,8 @@ static void tcp_v4_clear_md5_list (struct sock *sk) | |||
954 | } | 962 | } |
955 | } | 963 | } |
956 | 964 | ||
957 | static int tcp_v4_parse_md5_keys (struct sock *sk, char __user *optval, | 965 | static int tcp_v4_parse_md5_keys(struct sock *sk, char __user *optval, |
958 | int optlen) | 966 | int optlen) |
959 | { | 967 | { |
960 | struct tcp_md5sig cmd; | 968 | struct tcp_md5sig cmd; |
961 | struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.tcpm_addr; | 969 | struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.tcpm_addr; |
@@ -964,7 +972,7 @@ static int tcp_v4_parse_md5_keys (struct sock *sk, char __user *optval, | |||
964 | if (optlen < sizeof(cmd)) | 972 | if (optlen < sizeof(cmd)) |
965 | return -EINVAL; | 973 | return -EINVAL; |
966 | 974 | ||
967 | if (copy_from_user (&cmd, optval, sizeof(cmd))) | 975 | if (copy_from_user(&cmd, optval, sizeof(cmd))) |
968 | return -EFAULT; | 976 | return -EFAULT; |
969 | 977 | ||
970 | if (sin->sin_family != AF_INET) | 978 | if (sin->sin_family != AF_INET) |
@@ -981,9 +989,8 @@ static int tcp_v4_parse_md5_keys (struct sock *sk, char __user *optval, | |||
981 | 989 | ||
982 | if (!tcp_sk(sk)->md5sig_info) { | 990 | if (!tcp_sk(sk)->md5sig_info) { |
983 | struct tcp_sock *tp = tcp_sk(sk); | 991 | struct tcp_sock *tp = tcp_sk(sk); |
984 | struct tcp_md5sig_info *p; | 992 | struct tcp_md5sig_info *p = kzalloc(sizeof(*p), GFP_KERNEL); |
985 | 993 | ||
986 | p = kzalloc(sizeof(struct tcp_md5sig_info), GFP_KERNEL); | ||
987 | if (!p) | 994 | if (!p) |
988 | return -EINVAL; | 995 | return -EINVAL; |
989 | 996 | ||
@@ -1044,8 +1051,8 @@ static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, | |||
1044 | 1051 | ||
1045 | #ifdef CONFIG_TCP_MD5SIG_DEBUG | 1052 | #ifdef CONFIG_TCP_MD5SIG_DEBUG |
1046 | printk("Calcuating hash for: "); | 1053 | printk("Calcuating hash for: "); |
1047 | for (i = 0; i < sizeof (*bp); i++) | 1054 | for (i = 0; i < sizeof(*bp); i++) |
1048 | printk ("%02x ", (unsigned int)((unsigned char *)bp)[i]); | 1055 | printk("%02x ", (unsigned int)((unsigned char *)bp)[i]); |
1049 | printk(" "); | 1056 | printk(" "); |
1050 | #endif | 1057 | #endif |
1051 | 1058 | ||
@@ -1057,8 +1064,8 @@ static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, | |||
1057 | sg_set_buf(&sg[block++], th, sizeof(struct tcphdr)); | 1064 | sg_set_buf(&sg[block++], th, sizeof(struct tcphdr)); |
1058 | nbytes += sizeof(struct tcphdr); | 1065 | nbytes += sizeof(struct tcphdr); |
1059 | #ifdef CONFIG_TCP_MD5SIG_DEBUG | 1066 | #ifdef CONFIG_TCP_MD5SIG_DEBUG |
1060 | for (i = 0; i < sizeof (struct tcphdr); i++) | 1067 | for (i = 0; i < sizeof(struct tcphdr); i++) |
1061 | printk (" %02x", (unsigned int)((unsigned char *)th)[i]); | 1068 | printk(" %02x", (unsigned int)((unsigned char *)th)[i]); |
1062 | #endif | 1069 | #endif |
1063 | /* 3. the TCP segment data (if any) */ | 1070 | /* 3. the TCP segment data (if any) */ |
1064 | data_len = tcplen - (th->doff << 2); | 1071 | data_len = tcplen - (th->doff << 2); |
@@ -1075,9 +1082,9 @@ static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, | |||
1075 | nbytes += key->keylen; | 1082 | nbytes += key->keylen; |
1076 | 1083 | ||
1077 | #ifdef CONFIG_TCP_MD5SIG_DEBUG | 1084 | #ifdef CONFIG_TCP_MD5SIG_DEBUG |
1078 | printk (" and password: "); | 1085 | printk(" and password: "); |
1079 | for (i = 0; i < key->keylen; i++) | 1086 | for (i = 0; i < key->keylen; i++) |
1080 | printk ("%02x ", (unsigned int)key->key[i]); | 1087 | printk("%02x ", (unsigned int)key->key[i]); |
1081 | #endif | 1088 | #endif |
1082 | 1089 | ||
1083 | /* Now store the Hash into the packet */ | 1090 | /* Now store the Hash into the packet */ |
@@ -1099,7 +1106,7 @@ out: | |||
1099 | #ifdef CONFIG_TCP_MD5SIG_DEBUG | 1106 | #ifdef CONFIG_TCP_MD5SIG_DEBUG |
1100 | printk(" result:"); | 1107 | printk(" result:"); |
1101 | for (i = 0; i < 16; i++) | 1108 | for (i = 0; i < 16; i++) |
1102 | printk (" %02x", (unsigned int)(((u8*)md5_hash)[i])); | 1109 | printk(" %02x", (unsigned int)(((u8*)md5_hash)[i])); |
1103 | printk("\n"); | 1110 | printk("\n"); |
1104 | #endif | 1111 | #endif |
1105 | return 0; | 1112 | return 0; |
@@ -1135,7 +1142,7 @@ int tcp_v4_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, | |||
1135 | 1142 | ||
1136 | EXPORT_SYMBOL(tcp_v4_calc_md5_hash); | 1143 | EXPORT_SYMBOL(tcp_v4_calc_md5_hash); |
1137 | 1144 | ||
1138 | static int tcp_v4_inbound_md5_hash (struct sock *sk, struct sk_buff *skb) | 1145 | static int tcp_v4_inbound_md5_hash(struct sock *sk, struct sk_buff *skb) |
1139 | { | 1146 | { |
1140 | /* | 1147 | /* |
1141 | * This gets called for each TCP segment that arrives | 1148 | * This gets called for each TCP segment that arrives |
@@ -1149,7 +1156,7 @@ static int tcp_v4_inbound_md5_hash (struct sock *sk, struct sk_buff *skb) | |||
1149 | struct tcp_md5sig_key *hash_expected; | 1156 | struct tcp_md5sig_key *hash_expected; |
1150 | struct iphdr *iph = skb->nh.iph; | 1157 | struct iphdr *iph = skb->nh.iph; |
1151 | struct tcphdr *th = skb->h.th; | 1158 | struct tcphdr *th = skb->h.th; |
1152 | int length = (th->doff << 2) - sizeof (struct tcphdr); | 1159 | int length = (th->doff << 2) - sizeof(struct tcphdr); |
1153 | int genhash; | 1160 | int genhash; |
1154 | unsigned char *ptr; | 1161 | unsigned char *ptr; |
1155 | unsigned char newhash[16]; | 1162 | unsigned char newhash[16]; |
@@ -1200,22 +1207,18 @@ done_opts: | |||
1200 | return 0; | 1207 | return 0; |
1201 | 1208 | ||
1202 | if (hash_expected && !hash_location) { | 1209 | if (hash_expected && !hash_location) { |
1203 | if (net_ratelimit()) { | 1210 | LIMIT_NETDEBUG(KERN_INFO "MD5 Hash NOT expected but found " |
1204 | printk(KERN_INFO "MD5 Hash NOT expected but found " | ||
1205 | "(" NIPQUAD_FMT ", %d)->(" NIPQUAD_FMT ", %d)\n", | 1211 | "(" NIPQUAD_FMT ", %d)->(" NIPQUAD_FMT ", %d)\n", |
1206 | NIPQUAD (iph->saddr), ntohs(th->source), | 1212 | NIPQUAD(iph->saddr), ntohs(th->source), |
1207 | NIPQUAD (iph->daddr), ntohs(th->dest)); | 1213 | NIPQUAD(iph->daddr), ntohs(th->dest)); |
1208 | } | ||
1209 | return 1; | 1214 | return 1; |
1210 | } | 1215 | } |
1211 | 1216 | ||
1212 | if (!hash_expected && hash_location) { | 1217 | if (!hash_expected && hash_location) { |
1213 | if (net_ratelimit()) { | 1218 | LIMIT_NETDEBUG(KERN_INFO "MD5 Hash NOT expected but found " |
1214 | printk(KERN_INFO "MD5 Hash NOT expected but found " | ||
1215 | "(" NIPQUAD_FMT ", %d)->(" NIPQUAD_FMT ", %d)\n", | 1219 | "(" NIPQUAD_FMT ", %d)->(" NIPQUAD_FMT ", %d)\n", |
1216 | NIPQUAD (iph->saddr), ntohs(th->source), | 1220 | NIPQUAD(iph->saddr), ntohs(th->source), |
1217 | NIPQUAD (iph->daddr), ntohs(th->dest)); | 1221 | NIPQUAD(iph->daddr), ntohs(th->dest)); |
1218 | } | ||
1219 | return 1; | 1222 | return 1; |
1220 | } | 1223 | } |
1221 | 1224 | ||
@@ -1232,15 +1235,16 @@ done_opts: | |||
1232 | if (net_ratelimit()) { | 1235 | if (net_ratelimit()) { |
1233 | printk(KERN_INFO "MD5 Hash failed for " | 1236 | printk(KERN_INFO "MD5 Hash failed for " |
1234 | "(" NIPQUAD_FMT ", %d)->(" NIPQUAD_FMT ", %d)%s\n", | 1237 | "(" NIPQUAD_FMT ", %d)->(" NIPQUAD_FMT ", %d)%s\n", |
1235 | NIPQUAD (iph->saddr), ntohs(th->source), | 1238 | NIPQUAD(iph->saddr), ntohs(th->source), |
1236 | NIPQUAD (iph->daddr), ntohs(th->dest), | 1239 | NIPQUAD(iph->daddr), ntohs(th->dest), |
1237 | genhash ? " tcp_v4_calc_md5_hash failed" : ""); | 1240 | genhash ? " tcp_v4_calc_md5_hash failed" : ""); |
1238 | #ifdef CONFIG_TCP_MD5SIG_DEBUG | 1241 | #ifdef CONFIG_TCP_MD5SIG_DEBUG |
1239 | do { | 1242 | do { |
1240 | int i; | 1243 | int i; |
1241 | printk("Received: "); | 1244 | printk("Received: "); |
1242 | for (i = 0; i < 16; i++) | 1245 | for (i = 0; i < 16; i++) |
1243 | printk("%02x ", 0xff & (int)hash_location[i]); | 1246 | printk("%02x ", |
1247 | 0xff & (int)hash_location[i]); | ||
1244 | printk("\n"); | 1248 | printk("\n"); |
1245 | printk("Calculated: "); | 1249 | printk("Calculated: "); |
1246 | for (i = 0; i < 16; i++) | 1250 | for (i = 0; i < 16; i++) |
@@ -1582,7 +1586,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) | |||
1582 | * o We're expecting an MD5'd packet and this is no MD5 tcp option | 1586 | * o We're expecting an MD5'd packet and this is no MD5 tcp option |
1583 | * o There is an MD5 option and we're not expecting one | 1587 | * o There is an MD5 option and we're not expecting one |
1584 | */ | 1588 | */ |
1585 | if (tcp_v4_inbound_md5_hash (sk, skb)) | 1589 | if (tcp_v4_inbound_md5_hash(sk, skb)) |
1586 | goto discard; | 1590 | goto discard; |
1587 | #endif | 1591 | #endif |
1588 | 1592 | ||
@@ -2155,7 +2159,7 @@ static void *established_get_idx(struct seq_file *seq, loff_t pos) | |||
2155 | while (rc && pos) { | 2159 | while (rc && pos) { |
2156 | rc = established_get_next(seq, rc); | 2160 | rc = established_get_next(seq, rc); |
2157 | --pos; | 2161 | --pos; |
2158 | } | 2162 | } |
2159 | return rc; | 2163 | return rc; |
2160 | } | 2164 | } |
2161 | 2165 | ||
@@ -2284,7 +2288,7 @@ int tcp_proc_register(struct tcp_seq_afinfo *afinfo) | |||
2284 | afinfo->seq_fops->read = seq_read; | 2288 | afinfo->seq_fops->read = seq_read; |
2285 | afinfo->seq_fops->llseek = seq_lseek; | 2289 | afinfo->seq_fops->llseek = seq_lseek; |
2286 | afinfo->seq_fops->release = seq_release_private; | 2290 | afinfo->seq_fops->release = seq_release_private; |
2287 | 2291 | ||
2288 | p = proc_net_fops_create(afinfo->name, S_IRUGO, afinfo->seq_fops); | 2292 | p = proc_net_fops_create(afinfo->name, S_IRUGO, afinfo->seq_fops); |
2289 | if (p) | 2293 | if (p) |
2290 | p->data = afinfo; | 2294 | p->data = afinfo; |
@@ -2298,7 +2302,7 @@ void tcp_proc_unregister(struct tcp_seq_afinfo *afinfo) | |||
2298 | if (!afinfo) | 2302 | if (!afinfo) |
2299 | return; | 2303 | return; |
2300 | proc_net_remove(afinfo->name); | 2304 | proc_net_remove(afinfo->name); |
2301 | memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops)); | 2305 | memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops)); |
2302 | } | 2306 | } |
2303 | 2307 | ||
2304 | static void get_openreq4(struct sock *sk, struct request_sock *req, | 2308 | static void get_openreq4(struct sock *sk, struct request_sock *req, |
@@ -2356,7 +2360,8 @@ static void get_tcp4_sock(struct sock *sp, char *tmpbuf, int i) | |||
2356 | "%08X %5d %8d %lu %d %p %u %u %u %u %d", | 2360 | "%08X %5d %8d %lu %d %p %u %u %u %u %d", |
2357 | i, src, srcp, dest, destp, sp->sk_state, | 2361 | i, src, srcp, dest, destp, sp->sk_state, |
2358 | tp->write_seq - tp->snd_una, | 2362 | tp->write_seq - tp->snd_una, |
2359 | (sp->sk_state == TCP_LISTEN) ? sp->sk_ack_backlog : (tp->rcv_nxt - tp->copied_seq), | 2363 | sp->sk_state == TCP_LISTEN ? sp->sk_ack_backlog : |
2364 | (tp->rcv_nxt - tp->copied_seq), | ||
2360 | timer_active, | 2365 | timer_active, |
2361 | jiffies_to_clock_t(timer_expires - jiffies), | 2366 | jiffies_to_clock_t(timer_expires - jiffies), |
2362 | icsk->icsk_retransmits, | 2367 | icsk->icsk_retransmits, |
@@ -2371,7 +2376,8 @@ static void get_tcp4_sock(struct sock *sp, char *tmpbuf, int i) | |||
2371 | tp->snd_ssthresh >= 0xFFFF ? -1 : tp->snd_ssthresh); | 2376 | tp->snd_ssthresh >= 0xFFFF ? -1 : tp->snd_ssthresh); |
2372 | } | 2377 | } |
2373 | 2378 | ||
2374 | static void get_timewait4_sock(struct inet_timewait_sock *tw, char *tmpbuf, int i) | 2379 | static void get_timewait4_sock(struct inet_timewait_sock *tw, |
2380 | char *tmpbuf, int i) | ||
2375 | { | 2381 | { |
2376 | __be32 dest, src; | 2382 | __be32 dest, src; |
2377 | __u16 destp, srcp; | 2383 | __u16 destp, srcp; |
@@ -2484,7 +2490,8 @@ struct proto tcp_prot = { | |||
2484 | 2490 | ||
2485 | void __init tcp_v4_init(struct net_proto_family *ops) | 2491 | void __init tcp_v4_init(struct net_proto_family *ops) |
2486 | { | 2492 | { |
2487 | if (inet_csk_ctl_sock_create(&tcp_socket, PF_INET, SOCK_RAW, IPPROTO_TCP) < 0) | 2493 | if (inet_csk_ctl_sock_create(&tcp_socket, PF_INET, SOCK_RAW, |
2494 | IPPROTO_TCP) < 0) | ||
2488 | panic("Failed to create the TCP control socket.\n"); | 2495 | panic("Failed to create the TCP control socket.\n"); |
2489 | } | 2496 | } |
2490 | 2497 | ||