diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2005-08-12 11:51:49 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:57:44 -0400 |
commit | 73c1f4a033675f168df7e98bbeeafca3c644b8a6 (patch) | |
tree | 041e0c203be710b39c8b3a1c18d23e7a50e321a6 /net/ipv4/tcp_diag.c | |
parent | 4f5736c4c7cf6f9bd8db82b712cfdd51c87e06b9 (diff) |
[TCPDIAG]: Just rename everything to inet_diag
Next changeset will rename tcp_diag.[ch] to inet_diag.[ch].
I'm taking this longer route so as to easy review, making clear the changes
made all along the way.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_diag.c')
-rw-r--r-- | net/ipv4/tcp_diag.c | 391 |
1 files changed, 196 insertions, 195 deletions
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c index b13b71cb9ced..24abe82e23a0 100644 --- a/net/ipv4/tcp_diag.c +++ b/net/ipv4/tcp_diag.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * tcp_diag.c Module for monitoring TCP sockets. | 2 | * inet_diag.c Module for monitoring INET transport protocols sockets. |
3 | * | 3 | * |
4 | * Version: $Id: tcp_diag.c,v 1.3 2002/02/01 22:01:04 davem Exp $ | 4 | * Version: $Id: inet_diag.c,v 1.3 2002/02/01 22:01:04 davem Exp $ |
5 | * | 5 | * |
6 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 6 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
7 | * | 7 | * |
@@ -36,8 +36,7 @@ | |||
36 | 36 | ||
37 | static const struct inet_diag_handler **inet_diag_table; | 37 | static const struct inet_diag_handler **inet_diag_table; |
38 | 38 | ||
39 | struct tcpdiag_entry | 39 | struct inet_diag_entry { |
40 | { | ||
41 | u32 *saddr; | 40 | u32 *saddr; |
42 | u32 *daddr; | 41 | u32 *daddr; |
43 | u16 sport; | 42 | u16 sport; |
@@ -46,25 +45,21 @@ struct tcpdiag_entry | |||
46 | u16 userlocks; | 45 | u16 userlocks; |
47 | }; | 46 | }; |
48 | 47 | ||
49 | static struct sock *tcpnl; | 48 | static struct sock *idiagnl; |
50 | 49 | ||
51 | #define TCPDIAG_PUT(skb, attrtype, attrlen) \ | 50 | #define INET_DIAG_PUT(skb, attrtype, attrlen) \ |
52 | RTA_DATA(__RTA_PUT(skb, attrtype, attrlen)) | 51 | RTA_DATA(__RTA_PUT(skb, attrtype, attrlen)) |
53 | 52 | ||
54 | #ifdef CONFIG_IP_TCPDIAG_DCCP | 53 | static int inet_diag_fill(struct sk_buff *skb, struct sock *sk, |
55 | extern struct inet_hashinfo dccp_hashinfo; | ||
56 | #endif | ||
57 | |||
58 | static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk, | ||
59 | int ext, u32 pid, u32 seq, u16 nlmsg_flags, | 54 | int ext, u32 pid, u32 seq, u16 nlmsg_flags, |
60 | const struct nlmsghdr *unlh) | 55 | const struct nlmsghdr *unlh) |
61 | { | 56 | { |
62 | const struct inet_sock *inet = inet_sk(sk); | 57 | const struct inet_sock *inet = inet_sk(sk); |
63 | const struct inet_connection_sock *icsk = inet_csk(sk); | 58 | const struct inet_connection_sock *icsk = inet_csk(sk); |
64 | struct tcpdiagmsg *r; | 59 | struct inet_diag_msg *r; |
65 | struct nlmsghdr *nlh; | 60 | struct nlmsghdr *nlh; |
66 | void *info = NULL; | 61 | void *info = NULL; |
67 | struct tcpdiag_meminfo *minfo = NULL; | 62 | struct inet_diag_meminfo *minfo = NULL; |
68 | unsigned char *b = skb->tail; | 63 | unsigned char *b = skb->tail; |
69 | const struct inet_diag_handler *handler; | 64 | const struct inet_diag_handler *handler; |
70 | 65 | ||
@@ -76,51 +71,52 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk, | |||
76 | 71 | ||
77 | r = NLMSG_DATA(nlh); | 72 | r = NLMSG_DATA(nlh); |
78 | if (sk->sk_state != TCP_TIME_WAIT) { | 73 | if (sk->sk_state != TCP_TIME_WAIT) { |
79 | if (ext & (1<<(TCPDIAG_MEMINFO-1))) | 74 | if (ext & (1 << (INET_DIAG_MEMINFO - 1))) |
80 | minfo = TCPDIAG_PUT(skb, TCPDIAG_MEMINFO, sizeof(*minfo)); | 75 | minfo = INET_DIAG_PUT(skb, INET_DIAG_MEMINFO, |
81 | if (ext & (1<<(TCPDIAG_INFO-1))) | 76 | sizeof(*minfo)); |
82 | info = TCPDIAG_PUT(skb, TCPDIAG_INFO, | 77 | if (ext & (1 << (INET_DIAG_INFO - 1))) |
78 | info = INET_DIAG_PUT(skb, INET_DIAG_INFO, | ||
83 | handler->idiag_info_size); | 79 | handler->idiag_info_size); |
84 | 80 | ||
85 | if ((ext & (1 << (TCPDIAG_CONG - 1))) && icsk->icsk_ca_ops) { | 81 | if ((ext & (1 << (INET_DIAG_CONG - 1))) && icsk->icsk_ca_ops) { |
86 | size_t len = strlen(icsk->icsk_ca_ops->name); | 82 | size_t len = strlen(icsk->icsk_ca_ops->name); |
87 | strcpy(TCPDIAG_PUT(skb, TCPDIAG_CONG, len+1), | 83 | strcpy(INET_DIAG_PUT(skb, INET_DIAG_CONG, len + 1), |
88 | icsk->icsk_ca_ops->name); | 84 | icsk->icsk_ca_ops->name); |
89 | } | 85 | } |
90 | } | 86 | } |
91 | r->tcpdiag_family = sk->sk_family; | 87 | r->idiag_family = sk->sk_family; |
92 | r->tcpdiag_state = sk->sk_state; | 88 | r->idiag_state = sk->sk_state; |
93 | r->tcpdiag_timer = 0; | 89 | r->idiag_timer = 0; |
94 | r->tcpdiag_retrans = 0; | 90 | r->idiag_retrans = 0; |
95 | 91 | ||
96 | r->id.tcpdiag_if = sk->sk_bound_dev_if; | 92 | r->id.idiag_if = sk->sk_bound_dev_if; |
97 | r->id.tcpdiag_cookie[0] = (u32)(unsigned long)sk; | 93 | r->id.idiag_cookie[0] = (u32)(unsigned long)sk; |
98 | r->id.tcpdiag_cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1); | 94 | r->id.idiag_cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1); |
99 | 95 | ||
100 | if (r->tcpdiag_state == TCP_TIME_WAIT) { | 96 | if (r->idiag_state == TCP_TIME_WAIT) { |
101 | const struct inet_timewait_sock *tw = inet_twsk(sk); | 97 | const struct inet_timewait_sock *tw = inet_twsk(sk); |
102 | long tmo = tw->tw_ttd - jiffies; | 98 | long tmo = tw->tw_ttd - jiffies; |
103 | if (tmo < 0) | 99 | if (tmo < 0) |
104 | tmo = 0; | 100 | tmo = 0; |
105 | 101 | ||
106 | r->id.tcpdiag_sport = tw->tw_sport; | 102 | r->id.idiag_sport = tw->tw_sport; |
107 | r->id.tcpdiag_dport = tw->tw_dport; | 103 | r->id.idiag_dport = tw->tw_dport; |
108 | r->id.tcpdiag_src[0] = tw->tw_rcv_saddr; | 104 | r->id.idiag_src[0] = tw->tw_rcv_saddr; |
109 | r->id.tcpdiag_dst[0] = tw->tw_daddr; | 105 | r->id.idiag_dst[0] = tw->tw_daddr; |
110 | r->tcpdiag_state = tw->tw_substate; | 106 | r->idiag_state = tw->tw_substate; |
111 | r->tcpdiag_timer = 3; | 107 | r->idiag_timer = 3; |
112 | r->tcpdiag_expires = (tmo*1000+HZ-1)/HZ; | 108 | r->idiag_expires = (tmo * 1000 + HZ - 1) / HZ; |
113 | r->tcpdiag_rqueue = 0; | 109 | r->idiag_rqueue = 0; |
114 | r->tcpdiag_wqueue = 0; | 110 | r->idiag_wqueue = 0; |
115 | r->tcpdiag_uid = 0; | 111 | r->idiag_uid = 0; |
116 | r->tcpdiag_inode = 0; | 112 | r->idiag_inode = 0; |
117 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 113 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
118 | if (r->tcpdiag_family == AF_INET6) { | 114 | if (r->idiag_family == AF_INET6) { |
119 | const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk); | 115 | const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk); |
120 | 116 | ||
121 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src, | 117 | ipv6_addr_copy((struct in6_addr *)r->id.idiag_src, |
122 | &tcp6tw->tw_v6_rcv_saddr); | 118 | &tcp6tw->tw_v6_rcv_saddr); |
123 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst, | 119 | ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst, |
124 | &tcp6tw->tw_v6_daddr); | 120 | &tcp6tw->tw_v6_daddr); |
125 | } | 121 | } |
126 | #endif | 122 | #endif |
@@ -128,18 +124,18 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk, | |||
128 | return skb->len; | 124 | return skb->len; |
129 | } | 125 | } |
130 | 126 | ||
131 | r->id.tcpdiag_sport = inet->sport; | 127 | r->id.idiag_sport = inet->sport; |
132 | r->id.tcpdiag_dport = inet->dport; | 128 | r->id.idiag_dport = inet->dport; |
133 | r->id.tcpdiag_src[0] = inet->rcv_saddr; | 129 | r->id.idiag_src[0] = inet->rcv_saddr; |
134 | r->id.tcpdiag_dst[0] = inet->daddr; | 130 | r->id.idiag_dst[0] = inet->daddr; |
135 | 131 | ||
136 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 132 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
137 | if (r->tcpdiag_family == AF_INET6) { | 133 | if (r->idiag_family == AF_INET6) { |
138 | struct ipv6_pinfo *np = inet6_sk(sk); | 134 | struct ipv6_pinfo *np = inet6_sk(sk); |
139 | 135 | ||
140 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src, | 136 | ipv6_addr_copy((struct in6_addr *)r->id.idiag_src, |
141 | &np->rcv_saddr); | 137 | &np->rcv_saddr); |
142 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst, | 138 | ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst, |
143 | &np->daddr); | 139 | &np->daddr); |
144 | } | 140 | } |
145 | #endif | 141 | #endif |
@@ -147,31 +143,31 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk, | |||
147 | #define EXPIRES_IN_MS(tmo) ((tmo-jiffies)*1000+HZ-1)/HZ | 143 | #define EXPIRES_IN_MS(tmo) ((tmo-jiffies)*1000+HZ-1)/HZ |
148 | 144 | ||
149 | if (icsk->icsk_pending == ICSK_TIME_RETRANS) { | 145 | if (icsk->icsk_pending == ICSK_TIME_RETRANS) { |
150 | r->tcpdiag_timer = 1; | 146 | r->idiag_timer = 1; |
151 | r->tcpdiag_retrans = icsk->icsk_retransmits; | 147 | r->idiag_retrans = icsk->icsk_retransmits; |
152 | r->tcpdiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout); | 148 | r->idiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout); |
153 | } else if (icsk->icsk_pending == ICSK_TIME_PROBE0) { | 149 | } else if (icsk->icsk_pending == ICSK_TIME_PROBE0) { |
154 | r->tcpdiag_timer = 4; | 150 | r->idiag_timer = 4; |
155 | r->tcpdiag_retrans = icsk->icsk_probes_out; | 151 | r->idiag_retrans = icsk->icsk_probes_out; |
156 | r->tcpdiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout); | 152 | r->idiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout); |
157 | } else if (timer_pending(&sk->sk_timer)) { | 153 | } else if (timer_pending(&sk->sk_timer)) { |
158 | r->tcpdiag_timer = 2; | 154 | r->idiag_timer = 2; |
159 | r->tcpdiag_retrans = icsk->icsk_probes_out; | 155 | r->idiag_retrans = icsk->icsk_probes_out; |
160 | r->tcpdiag_expires = EXPIRES_IN_MS(sk->sk_timer.expires); | 156 | r->idiag_expires = EXPIRES_IN_MS(sk->sk_timer.expires); |
161 | } else { | 157 | } else { |
162 | r->tcpdiag_timer = 0; | 158 | r->idiag_timer = 0; |
163 | r->tcpdiag_expires = 0; | 159 | r->idiag_expires = 0; |
164 | } | 160 | } |
165 | #undef EXPIRES_IN_MS | 161 | #undef EXPIRES_IN_MS |
166 | 162 | ||
167 | r->tcpdiag_uid = sock_i_uid(sk); | 163 | r->idiag_uid = sock_i_uid(sk); |
168 | r->tcpdiag_inode = sock_i_ino(sk); | 164 | r->idiag_inode = sock_i_ino(sk); |
169 | 165 | ||
170 | if (minfo) { | 166 | if (minfo) { |
171 | minfo->tcpdiag_rmem = atomic_read(&sk->sk_rmem_alloc); | 167 | minfo->idiag_rmem = atomic_read(&sk->sk_rmem_alloc); |
172 | minfo->tcpdiag_wmem = sk->sk_wmem_queued; | 168 | minfo->idiag_wmem = sk->sk_wmem_queued; |
173 | minfo->tcpdiag_fmem = sk->sk_forward_alloc; | 169 | minfo->idiag_fmem = sk->sk_forward_alloc; |
174 | minfo->tcpdiag_tmem = atomic_read(&sk->sk_wmem_alloc); | 170 | minfo->idiag_tmem = atomic_read(&sk->sk_wmem_alloc); |
175 | } | 171 | } |
176 | 172 | ||
177 | handler->idiag_get_info(sk, r, info); | 173 | handler->idiag_get_info(sk, r, info); |
@@ -189,11 +185,11 @@ nlmsg_failure: | |||
189 | return -1; | 185 | return -1; |
190 | } | 186 | } |
191 | 187 | ||
192 | static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh) | 188 | static int inet_diag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh) |
193 | { | 189 | { |
194 | int err; | 190 | int err; |
195 | struct sock *sk; | 191 | struct sock *sk; |
196 | struct tcpdiagreq *req = NLMSG_DATA(nlh); | 192 | struct inet_diag_req *req = NLMSG_DATA(nlh); |
197 | struct sk_buff *rep; | 193 | struct sk_buff *rep; |
198 | struct inet_hashinfo *hashinfo; | 194 | struct inet_hashinfo *hashinfo; |
199 | const struct inet_diag_handler *handler; | 195 | const struct inet_diag_handler *handler; |
@@ -202,19 +198,19 @@ static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh) | |||
202 | BUG_ON(handler == NULL); | 198 | BUG_ON(handler == NULL); |
203 | hashinfo = handler->idiag_hashinfo; | 199 | hashinfo = handler->idiag_hashinfo; |
204 | 200 | ||
205 | if (req->tcpdiag_family == AF_INET) { | 201 | if (req->idiag_family == AF_INET) { |
206 | sk = inet_lookup(hashinfo, req->id.tcpdiag_dst[0], | 202 | sk = inet_lookup(hashinfo, req->id.idiag_dst[0], |
207 | req->id.tcpdiag_dport, req->id.tcpdiag_src[0], | 203 | req->id.idiag_dport, req->id.idiag_src[0], |
208 | req->id.tcpdiag_sport, req->id.tcpdiag_if); | 204 | req->id.idiag_sport, req->id.idiag_if); |
209 | } | 205 | } |
210 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 206 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
211 | else if (req->tcpdiag_family == AF_INET6) { | 207 | else if (req->idiag_family == AF_INET6) { |
212 | sk = inet6_lookup(hashinfo, | 208 | sk = inet6_lookup(hashinfo, |
213 | (struct in6_addr*)req->id.tcpdiag_dst, | 209 | (struct in6_addr *)req->id.idiag_dst, |
214 | req->id.tcpdiag_dport, | 210 | req->id.idiag_dport, |
215 | (struct in6_addr*)req->id.tcpdiag_src, | 211 | (struct in6_addr *)req->id.idiag_src, |
216 | req->id.tcpdiag_sport, | 212 | req->id.idiag_sport, |
217 | req->id.tcpdiag_if); | 213 | req->id.idiag_if); |
218 | } | 214 | } |
219 | #endif | 215 | #endif |
220 | else { | 216 | else { |
@@ -225,26 +221,27 @@ static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh) | |||
225 | return -ENOENT; | 221 | return -ENOENT; |
226 | 222 | ||
227 | err = -ESTALE; | 223 | err = -ESTALE; |
228 | if ((req->id.tcpdiag_cookie[0] != TCPDIAG_NOCOOKIE || | 224 | if ((req->id.idiag_cookie[0] != INET_DIAG_NOCOOKIE || |
229 | req->id.tcpdiag_cookie[1] != TCPDIAG_NOCOOKIE) && | 225 | req->id.idiag_cookie[1] != INET_DIAG_NOCOOKIE) && |
230 | ((u32)(unsigned long)sk != req->id.tcpdiag_cookie[0] || | 226 | ((u32)(unsigned long)sk != req->id.idiag_cookie[0] || |
231 | (u32)((((unsigned long)sk) >> 31) >> 1) != req->id.tcpdiag_cookie[1])) | 227 | (u32)((((unsigned long)sk) >> 31) >> 1) != req->id.idiag_cookie[1])) |
232 | goto out; | 228 | goto out; |
233 | 229 | ||
234 | err = -ENOMEM; | 230 | err = -ENOMEM; |
235 | rep = alloc_skb(NLMSG_SPACE((sizeof(struct tcpdiagmsg) + | 231 | rep = alloc_skb(NLMSG_SPACE((sizeof(struct inet_diag_msg) + |
236 | sizeof(struct tcpdiag_meminfo) + | 232 | sizeof(struct inet_diag_meminfo) + |
237 | handler->idiag_info_size + 64)), | 233 | handler->idiag_info_size + 64)), |
238 | GFP_KERNEL); | 234 | GFP_KERNEL); |
239 | if (!rep) | 235 | if (!rep) |
240 | goto out; | 236 | goto out; |
241 | 237 | ||
242 | if (tcpdiag_fill(rep, sk, req->tcpdiag_ext, | 238 | if (inet_diag_fill(rep, sk, req->idiag_ext, |
243 | NETLINK_CB(in_skb).pid, | 239 | NETLINK_CB(in_skb).pid, |
244 | nlh->nlmsg_seq, 0, nlh) <= 0) | 240 | nlh->nlmsg_seq, 0, nlh) <= 0) |
245 | BUG(); | 241 | BUG(); |
246 | 242 | ||
247 | err = netlink_unicast(tcpnl, rep, NETLINK_CB(in_skb).pid, MSG_DONTWAIT); | 243 | err = netlink_unicast(idiagnl, rep, NETLINK_CB(in_skb).pid, |
244 | MSG_DONTWAIT); | ||
248 | if (err > 0) | 245 | if (err > 0) |
249 | err = 0; | 246 | err = 0; |
250 | 247 | ||
@@ -285,42 +282,42 @@ static int bitstring_match(const u32 *a1, const u32 *a2, int bits) | |||
285 | } | 282 | } |
286 | 283 | ||
287 | 284 | ||
288 | static int tcpdiag_bc_run(const void *bc, int len, | 285 | static int inet_diag_bc_run(const void *bc, int len, |
289 | const struct tcpdiag_entry *entry) | 286 | const struct inet_diag_entry *entry) |
290 | { | 287 | { |
291 | while (len > 0) { | 288 | while (len > 0) { |
292 | int yes = 1; | 289 | int yes = 1; |
293 | const struct tcpdiag_bc_op *op = bc; | 290 | const struct inet_diag_bc_op *op = bc; |
294 | 291 | ||
295 | switch (op->code) { | 292 | switch (op->code) { |
296 | case TCPDIAG_BC_NOP: | 293 | case INET_DIAG_BC_NOP: |
297 | break; | 294 | break; |
298 | case TCPDIAG_BC_JMP: | 295 | case INET_DIAG_BC_JMP: |
299 | yes = 0; | 296 | yes = 0; |
300 | break; | 297 | break; |
301 | case TCPDIAG_BC_S_GE: | 298 | case INET_DIAG_BC_S_GE: |
302 | yes = entry->sport >= op[1].no; | 299 | yes = entry->sport >= op[1].no; |
303 | break; | 300 | break; |
304 | case TCPDIAG_BC_S_LE: | 301 | case INET_DIAG_BC_S_LE: |
305 | yes = entry->dport <= op[1].no; | 302 | yes = entry->dport <= op[1].no; |
306 | break; | 303 | break; |
307 | case TCPDIAG_BC_D_GE: | 304 | case INET_DIAG_BC_D_GE: |
308 | yes = entry->dport >= op[1].no; | 305 | yes = entry->dport >= op[1].no; |
309 | break; | 306 | break; |
310 | case TCPDIAG_BC_D_LE: | 307 | case INET_DIAG_BC_D_LE: |
311 | yes = entry->dport <= op[1].no; | 308 | yes = entry->dport <= op[1].no; |
312 | break; | 309 | break; |
313 | case TCPDIAG_BC_AUTO: | 310 | case INET_DIAG_BC_AUTO: |
314 | yes = !(entry->userlocks & SOCK_BINDPORT_LOCK); | 311 | yes = !(entry->userlocks & SOCK_BINDPORT_LOCK); |
315 | break; | 312 | break; |
316 | case TCPDIAG_BC_S_COND: | 313 | case INET_DIAG_BC_S_COND: |
317 | case TCPDIAG_BC_D_COND: | 314 | case INET_DIAG_BC_D_COND: |
318 | { | 315 | { |
319 | struct tcpdiag_hostcond *cond = (struct tcpdiag_hostcond*)(op+1); | 316 | struct inet_diag_hostcond *cond = (struct inet_diag_hostcond*)(op+1); |
320 | u32 *addr; | 317 | u32 *addr; |
321 | 318 | ||
322 | if (cond->port != -1 && | 319 | if (cond->port != -1 && |
323 | cond->port != (op->code == TCPDIAG_BC_S_COND ? | 320 | cond->port != (op->code == INET_DIAG_BC_S_COND ? |
324 | entry->sport : entry->dport)) { | 321 | entry->sport : entry->dport)) { |
325 | yes = 0; | 322 | yes = 0; |
326 | break; | 323 | break; |
@@ -329,7 +326,7 @@ static int tcpdiag_bc_run(const void *bc, int len, | |||
329 | if (cond->prefix_len == 0) | 326 | if (cond->prefix_len == 0) |
330 | break; | 327 | break; |
331 | 328 | ||
332 | if (op->code == TCPDIAG_BC_S_COND) | 329 | if (op->code == INET_DIAG_BC_S_COND) |
333 | addr = entry->saddr; | 330 | addr = entry->saddr; |
334 | else | 331 | else |
335 | addr = entry->daddr; | 332 | addr = entry->daddr; |
@@ -362,7 +359,7 @@ static int tcpdiag_bc_run(const void *bc, int len, | |||
362 | static int valid_cc(const void *bc, int len, int cc) | 359 | static int valid_cc(const void *bc, int len, int cc) |
363 | { | 360 | { |
364 | while (len >= 0) { | 361 | while (len >= 0) { |
365 | const struct tcpdiag_bc_op *op = bc; | 362 | const struct inet_diag_bc_op *op = bc; |
366 | 363 | ||
367 | if (cc > len) | 364 | if (cc > len) |
368 | return 0; | 365 | return 0; |
@@ -376,33 +373,33 @@ static int valid_cc(const void *bc, int len, int cc) | |||
376 | return 0; | 373 | return 0; |
377 | } | 374 | } |
378 | 375 | ||
379 | static int tcpdiag_bc_audit(const void *bytecode, int bytecode_len) | 376 | static int inet_diag_bc_audit(const void *bytecode, int bytecode_len) |
380 | { | 377 | { |
381 | const unsigned char *bc = bytecode; | 378 | const unsigned char *bc = bytecode; |
382 | int len = bytecode_len; | 379 | int len = bytecode_len; |
383 | 380 | ||
384 | while (len > 0) { | 381 | while (len > 0) { |
385 | struct tcpdiag_bc_op *op = (struct tcpdiag_bc_op*)bc; | 382 | struct inet_diag_bc_op *op = (struct inet_diag_bc_op*)bc; |
386 | 383 | ||
387 | //printk("BC: %d %d %d {%d} / %d\n", op->code, op->yes, op->no, op[1].no, len); | 384 | //printk("BC: %d %d %d {%d} / %d\n", op->code, op->yes, op->no, op[1].no, len); |
388 | switch (op->code) { | 385 | switch (op->code) { |
389 | case TCPDIAG_BC_AUTO: | 386 | case INET_DIAG_BC_AUTO: |
390 | case TCPDIAG_BC_S_COND: | 387 | case INET_DIAG_BC_S_COND: |
391 | case TCPDIAG_BC_D_COND: | 388 | case INET_DIAG_BC_D_COND: |
392 | case TCPDIAG_BC_S_GE: | 389 | case INET_DIAG_BC_S_GE: |
393 | case TCPDIAG_BC_S_LE: | 390 | case INET_DIAG_BC_S_LE: |
394 | case TCPDIAG_BC_D_GE: | 391 | case INET_DIAG_BC_D_GE: |
395 | case TCPDIAG_BC_D_LE: | 392 | case INET_DIAG_BC_D_LE: |
396 | if (op->yes < 4 || op->yes > len+4) | 393 | if (op->yes < 4 || op->yes > len+4) |
397 | return -EINVAL; | 394 | return -EINVAL; |
398 | case TCPDIAG_BC_JMP: | 395 | case INET_DIAG_BC_JMP: |
399 | if (op->no < 4 || op->no > len+4) | 396 | if (op->no < 4 || op->no > len+4) |
400 | return -EINVAL; | 397 | return -EINVAL; |
401 | if (op->no < len && | 398 | if (op->no < len && |
402 | !valid_cc(bytecode, bytecode_len, len-op->no)) | 399 | !valid_cc(bytecode, bytecode_len, len-op->no)) |
403 | return -EINVAL; | 400 | return -EINVAL; |
404 | break; | 401 | break; |
405 | case TCPDIAG_BC_NOP: | 402 | case INET_DIAG_BC_NOP: |
406 | if (op->yes < 4 || op->yes > len+4) | 403 | if (op->yes < 4 || op->yes > len+4) |
407 | return -EINVAL; | 404 | return -EINVAL; |
408 | break; | 405 | break; |
@@ -415,13 +412,13 @@ static int tcpdiag_bc_audit(const void *bytecode, int bytecode_len) | |||
415 | return len == 0 ? 0 : -EINVAL; | 412 | return len == 0 ? 0 : -EINVAL; |
416 | } | 413 | } |
417 | 414 | ||
418 | static int tcpdiag_dump_sock(struct sk_buff *skb, struct sock *sk, | 415 | static int inet_diag_dump_sock(struct sk_buff *skb, struct sock *sk, |
419 | struct netlink_callback *cb) | 416 | struct netlink_callback *cb) |
420 | { | 417 | { |
421 | struct tcpdiagreq *r = NLMSG_DATA(cb->nlh); | 418 | struct inet_diag_req *r = NLMSG_DATA(cb->nlh); |
422 | 419 | ||
423 | if (cb->nlh->nlmsg_len > 4 + NLMSG_SPACE(sizeof(*r))) { | 420 | if (cb->nlh->nlmsg_len > 4 + NLMSG_SPACE(sizeof(*r))) { |
424 | struct tcpdiag_entry entry; | 421 | struct inet_diag_entry entry; |
425 | struct rtattr *bc = (struct rtattr *)(r + 1); | 422 | struct rtattr *bc = (struct rtattr *)(r + 1); |
426 | struct inet_sock *inet = inet_sk(sk); | 423 | struct inet_sock *inet = inet_sk(sk); |
427 | 424 | ||
@@ -442,15 +439,15 @@ static int tcpdiag_dump_sock(struct sk_buff *skb, struct sock *sk, | |||
442 | entry.dport = ntohs(inet->dport); | 439 | entry.dport = ntohs(inet->dport); |
443 | entry.userlocks = sk->sk_userlocks; | 440 | entry.userlocks = sk->sk_userlocks; |
444 | 441 | ||
445 | if (!tcpdiag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), &entry)) | 442 | if (!inet_diag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), &entry)) |
446 | return 0; | 443 | return 0; |
447 | } | 444 | } |
448 | 445 | ||
449 | return tcpdiag_fill(skb, sk, r->tcpdiag_ext, NETLINK_CB(cb->skb).pid, | 446 | return inet_diag_fill(skb, sk, r->idiag_ext, NETLINK_CB(cb->skb).pid, |
450 | cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh); | 447 | cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh); |
451 | } | 448 | } |
452 | 449 | ||
453 | static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk, | 450 | static int inet_diag_fill_req(struct sk_buff *skb, struct sock *sk, |
454 | struct request_sock *req, | 451 | struct request_sock *req, |
455 | u32 pid, u32 seq, | 452 | u32 pid, u32 seq, |
456 | const struct nlmsghdr *unlh) | 453 | const struct nlmsghdr *unlh) |
@@ -458,7 +455,7 @@ static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk, | |||
458 | const struct inet_request_sock *ireq = inet_rsk(req); | 455 | const struct inet_request_sock *ireq = inet_rsk(req); |
459 | struct inet_sock *inet = inet_sk(sk); | 456 | struct inet_sock *inet = inet_sk(sk); |
460 | unsigned char *b = skb->tail; | 457 | unsigned char *b = skb->tail; |
461 | struct tcpdiagmsg *r; | 458 | struct inet_diag_msg *r; |
462 | struct nlmsghdr *nlh; | 459 | struct nlmsghdr *nlh; |
463 | long tmo; | 460 | long tmo; |
464 | 461 | ||
@@ -466,33 +463,33 @@ static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk, | |||
466 | nlh->nlmsg_flags = NLM_F_MULTI; | 463 | nlh->nlmsg_flags = NLM_F_MULTI; |
467 | r = NLMSG_DATA(nlh); | 464 | r = NLMSG_DATA(nlh); |
468 | 465 | ||
469 | r->tcpdiag_family = sk->sk_family; | 466 | r->idiag_family = sk->sk_family; |
470 | r->tcpdiag_state = TCP_SYN_RECV; | 467 | r->idiag_state = TCP_SYN_RECV; |
471 | r->tcpdiag_timer = 1; | 468 | r->idiag_timer = 1; |
472 | r->tcpdiag_retrans = req->retrans; | 469 | r->idiag_retrans = req->retrans; |
473 | 470 | ||
474 | r->id.tcpdiag_if = sk->sk_bound_dev_if; | 471 | r->id.idiag_if = sk->sk_bound_dev_if; |
475 | r->id.tcpdiag_cookie[0] = (u32)(unsigned long)req; | 472 | r->id.idiag_cookie[0] = (u32)(unsigned long)req; |
476 | r->id.tcpdiag_cookie[1] = (u32)(((unsigned long)req >> 31) >> 1); | 473 | r->id.idiag_cookie[1] = (u32)(((unsigned long)req >> 31) >> 1); |
477 | 474 | ||
478 | tmo = req->expires - jiffies; | 475 | tmo = req->expires - jiffies; |
479 | if (tmo < 0) | 476 | if (tmo < 0) |
480 | tmo = 0; | 477 | tmo = 0; |
481 | 478 | ||
482 | r->id.tcpdiag_sport = inet->sport; | 479 | r->id.idiag_sport = inet->sport; |
483 | r->id.tcpdiag_dport = ireq->rmt_port; | 480 | r->id.idiag_dport = ireq->rmt_port; |
484 | r->id.tcpdiag_src[0] = ireq->loc_addr; | 481 | r->id.idiag_src[0] = ireq->loc_addr; |
485 | r->id.tcpdiag_dst[0] = ireq->rmt_addr; | 482 | r->id.idiag_dst[0] = ireq->rmt_addr; |
486 | r->tcpdiag_expires = jiffies_to_msecs(tmo), | 483 | r->idiag_expires = jiffies_to_msecs(tmo); |
487 | r->tcpdiag_rqueue = 0; | 484 | r->idiag_rqueue = 0; |
488 | r->tcpdiag_wqueue = 0; | 485 | r->idiag_wqueue = 0; |
489 | r->tcpdiag_uid = sock_i_uid(sk); | 486 | r->idiag_uid = sock_i_uid(sk); |
490 | r->tcpdiag_inode = 0; | 487 | r->idiag_inode = 0; |
491 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 488 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
492 | if (r->tcpdiag_family == AF_INET6) { | 489 | if (r->idiag_family == AF_INET6) { |
493 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src, | 490 | ipv6_addr_copy((struct in6_addr *)r->id.idiag_src, |
494 | &tcp6_rsk(req)->loc_addr); | 491 | &tcp6_rsk(req)->loc_addr); |
495 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst, | 492 | ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst, |
496 | &tcp6_rsk(req)->rmt_addr); | 493 | &tcp6_rsk(req)->rmt_addr); |
497 | } | 494 | } |
498 | #endif | 495 | #endif |
@@ -505,11 +502,11 @@ nlmsg_failure: | |||
505 | return -1; | 502 | return -1; |
506 | } | 503 | } |
507 | 504 | ||
508 | static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk, | 505 | static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk, |
509 | struct netlink_callback *cb) | 506 | struct netlink_callback *cb) |
510 | { | 507 | { |
511 | struct tcpdiag_entry entry; | 508 | struct inet_diag_entry entry; |
512 | struct tcpdiagreq *r = NLMSG_DATA(cb->nlh); | 509 | struct inet_diag_req *r = NLMSG_DATA(cb->nlh); |
513 | struct inet_connection_sock *icsk = inet_csk(sk); | 510 | struct inet_connection_sock *icsk = inet_csk(sk); |
514 | struct listen_sock *lopt; | 511 | struct listen_sock *lopt; |
515 | struct rtattr *bc = NULL; | 512 | struct rtattr *bc = NULL; |
@@ -547,8 +544,8 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk, | |||
547 | 544 | ||
548 | if (reqnum < s_reqnum) | 545 | if (reqnum < s_reqnum) |
549 | continue; | 546 | continue; |
550 | if (r->id.tcpdiag_dport != ireq->rmt_port && | 547 | if (r->id.idiag_dport != ireq->rmt_port && |
551 | r->id.tcpdiag_dport) | 548 | r->id.idiag_dport) |
552 | continue; | 549 | continue; |
553 | 550 | ||
554 | if (bc) { | 551 | if (bc) { |
@@ -566,12 +563,12 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk, | |||
566 | &ireq->rmt_addr; | 563 | &ireq->rmt_addr; |
567 | entry.dport = ntohs(ireq->rmt_port); | 564 | entry.dport = ntohs(ireq->rmt_port); |
568 | 565 | ||
569 | if (!tcpdiag_bc_run(RTA_DATA(bc), | 566 | if (!inet_diag_bc_run(RTA_DATA(bc), |
570 | RTA_PAYLOAD(bc), &entry)) | 567 | RTA_PAYLOAD(bc), &entry)) |
571 | continue; | 568 | continue; |
572 | } | 569 | } |
573 | 570 | ||
574 | err = tcpdiag_fill_req(skb, sk, req, | 571 | err = inet_diag_fill_req(skb, sk, req, |
575 | NETLINK_CB(cb->skb).pid, | 572 | NETLINK_CB(cb->skb).pid, |
576 | cb->nlh->nlmsg_seq, cb->nlh); | 573 | cb->nlh->nlmsg_seq, cb->nlh); |
577 | if (err < 0) { | 574 | if (err < 0) { |
@@ -590,11 +587,11 @@ out: | |||
590 | return err; | 587 | return err; |
591 | } | 588 | } |
592 | 589 | ||
593 | static int tcpdiag_dump(struct sk_buff *skb, struct netlink_callback *cb) | 590 | static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) |
594 | { | 591 | { |
595 | int i, num; | 592 | int i, num; |
596 | int s_i, s_num; | 593 | int s_i, s_num; |
597 | struct tcpdiagreq *r = NLMSG_DATA(cb->nlh); | 594 | struct inet_diag_req *r = NLMSG_DATA(cb->nlh); |
598 | const struct inet_diag_handler *handler; | 595 | const struct inet_diag_handler *handler; |
599 | struct inet_hashinfo *hashinfo; | 596 | struct inet_hashinfo *hashinfo; |
600 | 597 | ||
@@ -606,7 +603,7 @@ static int tcpdiag_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
606 | s_num = num = cb->args[2]; | 603 | s_num = num = cb->args[2]; |
607 | 604 | ||
608 | if (cb->args[0] == 0) { | 605 | if (cb->args[0] == 0) { |
609 | if (!(r->tcpdiag_states&(TCPF_LISTEN|TCPF_SYN_RECV))) | 606 | if (!(r->idiag_states & (TCPF_LISTEN | TCPF_SYN_RECV))) |
610 | goto skip_listen_ht; | 607 | goto skip_listen_ht; |
611 | 608 | ||
612 | inet_listen_lock(hashinfo); | 609 | inet_listen_lock(hashinfo); |
@@ -623,25 +620,25 @@ static int tcpdiag_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
623 | continue; | 620 | continue; |
624 | } | 621 | } |
625 | 622 | ||
626 | if (r->id.tcpdiag_sport != inet->sport && | 623 | if (r->id.idiag_sport != inet->sport && |
627 | r->id.tcpdiag_sport) | 624 | r->id.idiag_sport) |
628 | goto next_listen; | 625 | goto next_listen; |
629 | 626 | ||
630 | if (!(r->tcpdiag_states&TCPF_LISTEN) || | 627 | if (!(r->idiag_states & TCPF_LISTEN) || |
631 | r->id.tcpdiag_dport || | 628 | r->id.idiag_dport || |
632 | cb->args[3] > 0) | 629 | cb->args[3] > 0) |
633 | goto syn_recv; | 630 | goto syn_recv; |
634 | 631 | ||
635 | if (tcpdiag_dump_sock(skb, sk, cb) < 0) { | 632 | if (inet_diag_dump_sock(skb, sk, cb) < 0) { |
636 | inet_listen_unlock(hashinfo); | 633 | inet_listen_unlock(hashinfo); |
637 | goto done; | 634 | goto done; |
638 | } | 635 | } |
639 | 636 | ||
640 | syn_recv: | 637 | syn_recv: |
641 | if (!(r->tcpdiag_states&TCPF_SYN_RECV)) | 638 | if (!(r->idiag_states & TCPF_SYN_RECV)) |
642 | goto next_listen; | 639 | goto next_listen; |
643 | 640 | ||
644 | if (tcpdiag_dump_reqs(skb, sk, cb) < 0) { | 641 | if (inet_diag_dump_reqs(skb, sk, cb) < 0) { |
645 | inet_listen_unlock(hashinfo); | 642 | inet_listen_unlock(hashinfo); |
646 | goto done; | 643 | goto done; |
647 | } | 644 | } |
@@ -662,7 +659,7 @@ skip_listen_ht: | |||
662 | s_i = num = s_num = 0; | 659 | s_i = num = s_num = 0; |
663 | } | 660 | } |
664 | 661 | ||
665 | if (!(r->tcpdiag_states&~(TCPF_LISTEN|TCPF_SYN_RECV))) | 662 | if (!(r->idiag_states & ~(TCPF_LISTEN | TCPF_SYN_RECV))) |
666 | return skb->len; | 663 | return skb->len; |
667 | 664 | ||
668 | for (i = s_i; i < hashinfo->ehash_size; i++) { | 665 | for (i = s_i; i < hashinfo->ehash_size; i++) { |
@@ -681,14 +678,14 @@ skip_listen_ht: | |||
681 | 678 | ||
682 | if (num < s_num) | 679 | if (num < s_num) |
683 | goto next_normal; | 680 | goto next_normal; |
684 | if (!(r->tcpdiag_states & (1 << sk->sk_state))) | 681 | if (!(r->idiag_states & (1 << sk->sk_state))) |
685 | goto next_normal; | 682 | goto next_normal; |
686 | if (r->id.tcpdiag_sport != inet->sport && | 683 | if (r->id.idiag_sport != inet->sport && |
687 | r->id.tcpdiag_sport) | 684 | r->id.idiag_sport) |
688 | goto next_normal; | 685 | goto next_normal; |
689 | if (r->id.tcpdiag_dport != inet->dport && r->id.tcpdiag_dport) | 686 | if (r->id.idiag_dport != inet->dport && r->id.idiag_dport) |
690 | goto next_normal; | 687 | goto next_normal; |
691 | if (tcpdiag_dump_sock(skb, sk, cb) < 0) { | 688 | if (inet_diag_dump_sock(skb, sk, cb) < 0) { |
692 | read_unlock_bh(&head->lock); | 689 | read_unlock_bh(&head->lock); |
693 | goto done; | 690 | goto done; |
694 | } | 691 | } |
@@ -696,20 +693,20 @@ next_normal: | |||
696 | ++num; | 693 | ++num; |
697 | } | 694 | } |
698 | 695 | ||
699 | if (r->tcpdiag_states&TCPF_TIME_WAIT) { | 696 | if (r->idiag_states & TCPF_TIME_WAIT) { |
700 | sk_for_each(sk, node, | 697 | sk_for_each(sk, node, |
701 | &hashinfo->ehash[i + hashinfo->ehash_size].chain) { | 698 | &hashinfo->ehash[i + hashinfo->ehash_size].chain) { |
702 | struct inet_sock *inet = inet_sk(sk); | 699 | struct inet_sock *inet = inet_sk(sk); |
703 | 700 | ||
704 | if (num < s_num) | 701 | if (num < s_num) |
705 | goto next_dying; | 702 | goto next_dying; |
706 | if (r->id.tcpdiag_sport != inet->sport && | 703 | if (r->id.idiag_sport != inet->sport && |
707 | r->id.tcpdiag_sport) | 704 | r->id.idiag_sport) |
708 | goto next_dying; | 705 | goto next_dying; |
709 | if (r->id.tcpdiag_dport != inet->dport && | 706 | if (r->id.idiag_dport != inet->dport && |
710 | r->id.tcpdiag_dport) | 707 | r->id.idiag_dport) |
711 | goto next_dying; | 708 | goto next_dying; |
712 | if (tcpdiag_dump_sock(skb, sk, cb) < 0) { | 709 | if (inet_diag_dump_sock(skb, sk, cb) < 0) { |
713 | read_unlock_bh(&head->lock); | 710 | read_unlock_bh(&head->lock); |
714 | goto done; | 711 | goto done; |
715 | } | 712 | } |
@@ -726,14 +723,14 @@ done: | |||
726 | return skb->len; | 723 | return skb->len; |
727 | } | 724 | } |
728 | 725 | ||
729 | static int tcpdiag_dump_done(struct netlink_callback *cb) | 726 | static int inet_diag_dump_done(struct netlink_callback *cb) |
730 | { | 727 | { |
731 | return 0; | 728 | return 0; |
732 | } | 729 | } |
733 | 730 | ||
734 | 731 | ||
735 | static __inline__ int | 732 | static __inline__ int |
736 | tcpdiag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | 733 | inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
737 | { | 734 | { |
738 | if (!(nlh->nlmsg_flags&NLM_F_REQUEST)) | 735 | if (!(nlh->nlmsg_flags&NLM_F_REQUEST)) |
739 | return 0; | 736 | return 0; |
@@ -744,24 +741,28 @@ tcpdiag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
744 | if (inet_diag_table[nlh->nlmsg_type] == NULL) | 741 | if (inet_diag_table[nlh->nlmsg_type] == NULL) |
745 | return -ENOENT; | 742 | return -ENOENT; |
746 | 743 | ||
747 | if (NLMSG_LENGTH(sizeof(struct tcpdiagreq)) > skb->len) | 744 | if (NLMSG_LENGTH(sizeof(struct inet_diag_req)) > skb->len) |
748 | goto err_inval; | 745 | goto err_inval; |
749 | 746 | ||
750 | if (nlh->nlmsg_flags&NLM_F_DUMP) { | 747 | if (nlh->nlmsg_flags&NLM_F_DUMP) { |
751 | if (nlh->nlmsg_len > 4 + NLMSG_SPACE(sizeof(struct tcpdiagreq))) { | 748 | if (nlh->nlmsg_len > |
752 | struct rtattr *rta = (struct rtattr*)(NLMSG_DATA(nlh) + sizeof(struct tcpdiagreq)); | 749 | (4 + NLMSG_SPACE(sizeof(struct inet_diag_req)))) { |
753 | if (rta->rta_type != TCPDIAG_REQ_BYTECODE || | 750 | struct rtattr *rta = (void *)(NLMSG_DATA(nlh) + |
751 | sizeof(struct inet_diag_req)); | ||
752 | if (rta->rta_type != INET_DIAG_REQ_BYTECODE || | ||
754 | rta->rta_len < 8 || | 753 | rta->rta_len < 8 || |
755 | rta->rta_len > nlh->nlmsg_len - NLMSG_SPACE(sizeof(struct tcpdiagreq))) | 754 | rta->rta_len > |
755 | (nlh->nlmsg_len - | ||
756 | NLMSG_SPACE(sizeof(struct inet_diag_req)))) | ||
756 | goto err_inval; | 757 | goto err_inval; |
757 | if (tcpdiag_bc_audit(RTA_DATA(rta), RTA_PAYLOAD(rta))) | 758 | if (inet_diag_bc_audit(RTA_DATA(rta), RTA_PAYLOAD(rta))) |
758 | goto err_inval; | 759 | goto err_inval; |
759 | } | 760 | } |
760 | return netlink_dump_start(tcpnl, skb, nlh, | 761 | return netlink_dump_start(idiagnl, skb, nlh, |
761 | tcpdiag_dump, | 762 | inet_diag_dump, |
762 | tcpdiag_dump_done); | 763 | inet_diag_dump_done); |
763 | } else { | 764 | } else { |
764 | return tcpdiag_get_exact(skb, nlh); | 765 | return inet_diag_get_exact(skb, nlh); |
765 | } | 766 | } |
766 | 767 | ||
767 | err_inval: | 768 | err_inval: |
@@ -769,7 +770,7 @@ err_inval: | |||
769 | } | 770 | } |
770 | 771 | ||
771 | 772 | ||
772 | static inline void tcpdiag_rcv_skb(struct sk_buff *skb) | 773 | static inline void inet_diag_rcv_skb(struct sk_buff *skb) |
773 | { | 774 | { |
774 | int err; | 775 | int err; |
775 | struct nlmsghdr * nlh; | 776 | struct nlmsghdr * nlh; |
@@ -778,31 +779,31 @@ static inline void tcpdiag_rcv_skb(struct sk_buff *skb) | |||
778 | nlh = (struct nlmsghdr *)skb->data; | 779 | nlh = (struct nlmsghdr *)skb->data; |
779 | if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len) | 780 | if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len) |
780 | return; | 781 | return; |
781 | err = tcpdiag_rcv_msg(skb, nlh); | 782 | err = inet_diag_rcv_msg(skb, nlh); |
782 | if (err || nlh->nlmsg_flags & NLM_F_ACK) | 783 | if (err || nlh->nlmsg_flags & NLM_F_ACK) |
783 | netlink_ack(skb, nlh, err); | 784 | netlink_ack(skb, nlh, err); |
784 | } | 785 | } |
785 | } | 786 | } |
786 | 787 | ||
787 | static void tcpdiag_rcv(struct sock *sk, int len) | 788 | static void inet_diag_rcv(struct sock *sk, int len) |
788 | { | 789 | { |
789 | struct sk_buff *skb; | 790 | struct sk_buff *skb; |
790 | unsigned int qlen = skb_queue_len(&sk->sk_receive_queue); | 791 | unsigned int qlen = skb_queue_len(&sk->sk_receive_queue); |
791 | 792 | ||
792 | while (qlen-- && (skb = skb_dequeue(&sk->sk_receive_queue))) { | 793 | while (qlen-- && (skb = skb_dequeue(&sk->sk_receive_queue))) { |
793 | tcpdiag_rcv_skb(skb); | 794 | inet_diag_rcv_skb(skb); |
794 | kfree_skb(skb); | 795 | kfree_skb(skb); |
795 | } | 796 | } |
796 | } | 797 | } |
797 | 798 | ||
798 | static void tcp_diag_get_info(struct sock *sk, struct tcpdiagmsg *r, | 799 | static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r, |
799 | void *_info) | 800 | void *_info) |
800 | { | 801 | { |
801 | const struct tcp_sock *tp = tcp_sk(sk); | 802 | const struct tcp_sock *tp = tcp_sk(sk); |
802 | struct tcp_info *info = _info; | 803 | struct tcp_info *info = _info; |
803 | 804 | ||
804 | r->tcpdiag_rqueue = tp->rcv_nxt - tp->copied_seq; | 805 | r->idiag_rqueue = tp->rcv_nxt - tp->copied_seq; |
805 | r->tcpdiag_wqueue = tp->write_seq - tp->snd_una; | 806 | r->idiag_wqueue = tp->write_seq - tp->snd_una; |
806 | if (info != NULL) | 807 | if (info != NULL) |
807 | tcp_get_info(sk, info); | 808 | tcp_get_info(sk, info); |
808 | } | 809 | } |
@@ -851,7 +852,7 @@ void inet_diag_unregister(const struct inet_diag_handler *h) | |||
851 | } | 852 | } |
852 | EXPORT_SYMBOL_GPL(inet_diag_unregister); | 853 | EXPORT_SYMBOL_GPL(inet_diag_unregister); |
853 | 854 | ||
854 | static int __init tcpdiag_init(void) | 855 | static int __init inet_diag_init(void) |
855 | { | 856 | { |
856 | const int inet_diag_table_size = (INET_DIAG_GETSOCK_MAX * | 857 | const int inet_diag_table_size = (INET_DIAG_GETSOCK_MAX * |
857 | sizeof(struct inet_diag_handler *)); | 858 | sizeof(struct inet_diag_handler *)); |
@@ -863,9 +864,9 @@ static int __init tcpdiag_init(void) | |||
863 | 864 | ||
864 | memset(inet_diag_table, 0, inet_diag_table_size); | 865 | memset(inet_diag_table, 0, inet_diag_table_size); |
865 | 866 | ||
866 | tcpnl = netlink_kernel_create(NETLINK_TCPDIAG, tcpdiag_rcv, | 867 | idiagnl = netlink_kernel_create(NETLINK_INET_DIAG, inet_diag_rcv, |
867 | THIS_MODULE); | 868 | THIS_MODULE); |
868 | if (tcpnl == NULL) | 869 | if (idiagnl == NULL) |
869 | goto out_free_table; | 870 | goto out_free_table; |
870 | 871 | ||
871 | err = inet_diag_register(&tcp_diag_handler); | 872 | err = inet_diag_register(&tcp_diag_handler); |
@@ -874,18 +875,18 @@ static int __init tcpdiag_init(void) | |||
874 | out: | 875 | out: |
875 | return err; | 876 | return err; |
876 | out_sock_release: | 877 | out_sock_release: |
877 | sock_release(tcpnl->sk_socket); | 878 | sock_release(idiagnl->sk_socket); |
878 | out_free_table: | 879 | out_free_table: |
879 | kfree(inet_diag_table); | 880 | kfree(inet_diag_table); |
880 | goto out; | 881 | goto out; |
881 | } | 882 | } |
882 | 883 | ||
883 | static void __exit tcpdiag_exit(void) | 884 | static void __exit inet_diag_exit(void) |
884 | { | 885 | { |
885 | sock_release(tcpnl->sk_socket); | 886 | sock_release(idiagnl->sk_socket); |
886 | kfree(inet_diag_table); | 887 | kfree(inet_diag_table); |
887 | } | 888 | } |
888 | 889 | ||
889 | module_init(tcpdiag_init); | 890 | module_init(inet_diag_init); |
890 | module_exit(tcpdiag_exit); | 891 | module_exit(inet_diag_exit); |
891 | MODULE_LICENSE("GPL"); | 892 | MODULE_LICENSE("GPL"); |