struct tcp_sock *tp = tcp_sk(sk); 
static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,			int ext, u32 pid, u32 seq, u16 nlmsg_flags){	const struct inet_sock *inet = inet_sk(sk);	struct tcp_sock *tp = tcp_sk(sk);	const struct inet_connection_sock *icsk = inet_csk(sk);	struct tcpdiagmsg *r;	struct nlmsghdr  *nlh;	struct tcp_info  *info = NULL;	struct tcpdiag_meminfo  *minfo = NULL;	unsigned char	 *b = skb->tail;	nlh = NLMSG_PUT(skb, pid, seq, TCPDIAG_GETSOCK, sizeof(*r));	nlh->nlmsg_flags = nlmsg_flags;	r = NLMSG_DATA(nlh);	if (sk->sk_state != TCP_TIME_WAIT) {		if (ext & (1<<(TCPDIAG_MEMINFO-1)))			minfo = TCPDIAG_PUT(skb, TCPDIAG_MEMINFO, sizeof(*minfo));		if (ext & (1<<(TCPDIAG_INFO-1)))			info = TCPDIAG_PUT(skb, TCPDIAG_INFO, sizeof(*info));				if ((ext & (1 << (TCPDIAG_CONG - 1))) && icsk->icsk_ca_ops) {			size_t len = strlen(icsk->icsk_ca_ops->name);			strcpy(TCPDIAG_PUT(skb, TCPDIAG_CONG, len+1),			       icsk->icsk_ca_ops->name);		}	}	r->tcpdiag_family = sk->sk_family;	r->tcpdiag_state = sk->sk_state;	r->tcpdiag_timer = 0;	r->tcpdiag_retrans = 0;	r->id.tcpdiag_if = sk->sk_bound_dev_if;	r->id.tcpdiag_cookie[0] = (u32)(unsigned long)sk;	r->id.tcpdiag_cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);	if (r->tcpdiag_state == TCP_TIME_WAIT) {		const struct inet_timewait_sock *tw = inet_twsk(sk);		long tmo = tw->tw_ttd - jiffies;		if (tmo < 0)			tmo = 0;		r->id.tcpdiag_sport = tw->tw_sport;		r->id.tcpdiag_dport = tw->tw_dport;		r->id.tcpdiag_src[0] = tw->tw_rcv_saddr;		r->id.tcpdiag_dst[0] = tw->tw_daddr;		r->tcpdiag_state = tw->tw_substate;		r->tcpdiag_timer = 3;		r->tcpdiag_expires = (tmo*1000+HZ-1)/HZ;		r->tcpdiag_rqueue = 0;		r->tcpdiag_wqueue = 0;		r->tcpdiag_uid = 0;		r->tcpdiag_inode = 0;#ifdef CONFIG_IP_TCPDIAG_IPV6		if (r->tcpdiag_family == AF_INET6) {			const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk);			ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src,				       &tcp6tw->tw_v6_rcv_saddr);			ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst,				       &tcp6tw->tw_v6_daddr);		}#endif		nlh->nlmsg_len = skb->tail - b;		return skb->len;	}	r->id.tcpdiag_sport = inet->sport;	r->id.tcpdiag_dport = inet->dport;	r->id.tcpdiag_src[0] = inet->rcv_saddr;	r->id.tcpdiag_dst[0] = inet->daddr;#ifdef CONFIG_IP_TCPDIAG_IPV6	if (r->tcpdiag_family == AF_INET6) {		struct ipv6_pinfo *np = inet6_sk(sk);		ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src,			       &np->rcv_saddr);		ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst,			       &np->daddr);	}#endif#define EXPIRES_IN_MS(tmo)  ((tmo-jiffies)*1000+HZ-1)/HZ	if (icsk->icsk_pending == ICSK_TIME_RETRANS) {		r->tcpdiag_timer = 1;		r->tcpdiag_retrans = icsk->icsk_retransmits;		r->tcpdiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout);	} else if (icsk->icsk_pending == ICSK_TIME_PROBE0) {		r->tcpdiag_timer = 4;		r->tcpdiag_retrans = icsk->icsk_probes_out;		r->tcpdiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout);	} else if (timer_pending(&sk->sk_timer)) {		r->tcpdiag_timer = 2;		r->tcpdiag_retrans = icsk->icsk_probes_out;		r->tcpdiag_expires = EXPIRES_IN_MS(sk->sk_timer.expires);	} else {		r->tcpdiag_timer = 0;		r->tcpdiag_expires = 0;	}#undef EXPIRES_IN_MS	r->tcpdiag_rqueue = tp->rcv_nxt - tp->copied_seq;	r->tcpdiag_wqueue = tp->write_seq - tp->snd_una;	r->tcpdiag_uid = sock_i_uid(sk);	r->tcpdiag_inode = sock_i_ino(sk);	if (minfo) {		minfo->tcpdiag_rmem = atomic_read(&sk->sk_rmem_alloc);		minfo->tcpdiag_wmem = sk->sk_wmem_queued;		minfo->tcpdiag_fmem = sk->sk_forward_alloc;		minfo->tcpdiag_tmem = atomic_read(&sk->sk_wmem_alloc);	}	if (info) 		tcp_get_info(sk, info);	if (sk->sk_state < TCP_TIME_WAIT &&	    icsk->icsk_ca_ops && icsk->icsk_ca_ops->get_info)		icsk->icsk_ca_ops->get_info(sk, ext, skb);	nlh->nlmsg_len = skb->tail - b;	return skb->len;rtattr_failure:nlmsg_failure:	skb_trim(skb, b - skb->data);	return -1;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/540722ffc3a0d7e11d97a13e1ce6f3bc23b061c1/tcp_diag.c/buggy/net/ipv4/tcp_diag.c