Esempio n. 1
0
static int inet_twsk_diag_dump(struct inet_timewait_sock *tw,
			       struct sk_buff *skb,
			       struct netlink_callback *cb,
			       struct inet_diag_req_v2 *r,
			       const struct nlattr *bc)
{
	if (bc != NULL) {
		struct inet_diag_entry entry;

		entry.family = tw->tw_family;
#if IS_ENABLED(CONFIG_IPV6)
		if (tw->tw_family == AF_INET6) {
			struct inet6_timewait_sock *tw6 =
						inet6_twsk((struct sock *)tw);
			entry.saddr = tw6->tw_v6_rcv_saddr.s6_addr32;
			entry.daddr = tw6->tw_v6_daddr.s6_addr32;
		} else
#endif
		{
			entry.saddr = &tw->tw_rcv_saddr;
			entry.daddr = &tw->tw_daddr;
		}
		entry.sport = tw->tw_num;
		entry.dport = ntohs(tw->tw_dport);
		entry.userlocks = 0;

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

	return inet_twsk_diag_fill(tw, skb, r,
				   NETLINK_CB(cb->skb).portid,
				   cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh);
}
Esempio n. 2
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 IS_ENABLED(CONFIG_IPV6)
	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);
}
Esempio n. 3
0
int inet_diag_bc_sk(const struct nlattr *bc, struct sock *sk)
{
	struct inet_sock *inet = inet_sk(sk);
	struct inet_diag_entry entry;

	if (!bc)
		return 1;

	entry.family = sk->sk_family;
	entry_fill_addrs(&entry, sk);
	entry.sport = inet->inet_num;
	entry.dport = ntohs(inet->inet_dport);
	entry.userlocks = sk_fullsock(sk) ? sk->sk_userlocks : 0;

	return inet_diag_bc_run(bc, &entry);
}
Esempio n. 4
0
int inet_diag_bc_sk(const struct nlattr *bc, struct sock *sk)
{
    struct inet_sock *inet = inet_sk(sk);
    struct inet_diag_entry entry;

    if (!bc)
        return 1;

    entry.family = sk->sk_family;
    entry_fill_addrs(&entry, sk);
    entry.sport = inet->inet_num;
    entry.dport = ntohs(inet->inet_dport);
    entry.ifindex = sk->sk_bound_dev_if;
    entry.userlocks = sk_fullsock(sk) ? sk->sk_userlocks : 0;
    if (sk_fullsock(sk))
        entry.mark = sk->sk_mark;
    else if (sk->sk_state == TCP_NEW_SYN_RECV)
        entry.mark = inet_rsk(inet_reqsk(sk))->ir_mark;
    else
        entry.mark = 0;

    return inet_diag_bc_run(bc, &entry);
}