Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 278545
b: refs/heads/master
c: 8d07d15
h: refs/heads/master
i:
  278543: 8c3f7ad
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Dec 9, 2011
1 parent dfac62a commit a5594f9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: efb3cb428dcde2356802b3f93e152efa7abc5a62
refs/heads/master: 8d07d1518a074a08b90be02eee5ee15e60ac9779
2 changes: 2 additions & 0 deletions trunk/include/linux/inet_diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ struct tcpvegas_info {
#ifdef __KERNEL__
struct sock;
struct inet_hashinfo;
struct nlattr;

struct inet_diag_handler {
struct inet_hashinfo *idiag_hashinfo;
Expand All @@ -144,6 +145,7 @@ struct inet_diag_handler {
__u16 idiag_type;
};

int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
int inet_diag_check_cookie(struct sock *sk, struct inet_diag_req *req);

extern int inet_diag_register(const struct inet_diag_handler *handler);
Expand Down
55 changes: 31 additions & 24 deletions trunk/net/ipv4/inet_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,35 @@ static int inet_diag_bc_run(const struct nlattr *_bc,
return len == 0;
}

int inet_diag_bc_sk(const struct nlattr *bc, struct sock *sk)
{
struct inet_diag_entry entry;
struct inet_sock *inet = inet_sk(sk);

if (bc == NULL)
return 1;

entry.family = sk->sk_family;
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
if (entry.family == AF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk);

entry.saddr = np->rcv_saddr.s6_addr32;
entry.daddr = np->daddr.s6_addr32;
} else
#endif
{
entry.saddr = &inet->inet_rcv_saddr;
entry.daddr = &inet->inet_daddr;
}
entry.sport = inet->inet_num;
entry.dport = ntohs(inet->inet_dport);
entry.userlocks = sk->sk_userlocks;

return inet_diag_bc_run(bc, &entry);
}
EXPORT_SYMBOL_GPL(inet_diag_bc_sk);

static int valid_cc(const void *bc, int len, int cc)
{
while (len >= 0) {
Expand Down Expand Up @@ -509,30 +538,8 @@ static int inet_csk_diag_dump(struct sock *sk,
struct inet_diag_req *r,
const struct nlattr *bc)
{
if (bc != NULL) {
struct inet_diag_entry entry;
struct inet_sock *inet = inet_sk(sk);

entry.family = sk->sk_family;
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
if (entry.family == AF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk);

entry.saddr = np->rcv_saddr.s6_addr32;
entry.daddr = np->daddr.s6_addr32;
} else
#endif
{
entry.saddr = &inet->inet_rcv_saddr;
entry.daddr = &inet->inet_daddr;
}
entry.sport = inet->inet_num;
entry.dport = ntohs(inet->inet_dport);
entry.userlocks = sk->sk_userlocks;

if (!inet_diag_bc_run(bc, &entry))
return 0;
}
if (!inet_diag_bc_sk(bc, sk))
return 0;

return inet_csk_diag_fill(sk, skb, r,
NETLINK_CB(cb->skb).pid,
Expand Down

0 comments on commit a5594f9

Please sign in to comment.