lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Mon, 4 Aug 2014 14:32:45 +0100
From:	Zoltan Kiss <zoltan.kiss@...rix.com>
To:	David Miller <davem@...emloft.net>
CC:	<steffen.klassert@...unet.com>, <minipli@...glemail.com>,
	<dborkman@...hat.com>, <tgraf@...g.ch>, <joe@...ches.com>,
	<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<xen-devel@...ts.xenproject.org>
Subject: Re: [PATCH net-next v3 4/4 RFC] pktgen: Allow sending IPv4 TCP packets

On 01/08/14 05:32, David Miller wrote:
> From: Zoltan Kiss <zoltan.kiss@...rix.com>
>> @@ -3017,29 +3029,40 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
>>   	iph = (struct iphdr *) skb_put(skb, sizeof(struct iphdr));
>>
>>   	skb_set_transport_header(skb, skb->len);
>> -	udph = (struct udphdr *) skb_put(skb, sizeof(struct udphdr));
>> +
>> +	if (pkt_dev->flags & F_TCP) {
>> +		datalen = pkt_dev->cur_pkt_size - ETH_HLEN - 20 -
>> +			  sizeof(struct tcphdr) - pkt_dev->pkt_overhead;
>> +		tcph = (struct tcphdr *)skb_put(skb, sizeof(struct tcphdr));
>> +		memset(tcph, 0, sizeof(*tcph));
>> +		tcph->source = htons(pkt_dev->cur_udp_src);
>> +		tcph->dest = htons(pkt_dev->cur_udp_dst);
>> +		tcph->doff = sizeof(struct tcphdr) >> 2;
>> +	} else {
>> +		datalen = pkt_dev->cur_pkt_size - ETH_HLEN - 20 -
>> +			  sizeof(struct udphdr) - pkt_dev->pkt_overhead;
>> +		udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr));
>> +		udph->source = htons(pkt_dev->cur_udp_src);
>> +		udph->dest = htons(pkt_dev->cur_udp_dst);
>> +		udph->len = htons(datalen + sizeof(struct udphdr));
>> +		udph->check = 0;
>> +	}
>> +
>
> As more protocols (SCTP, etc.) get supported, this is going to become
> completely unmanageable.  Please use callbacks or something like that
> so this function doesn't turn into even more spaghetti.
OK

>
>> +	} else if (pkt_dev->flags & F_TCP) {
>> +		struct inet_sock inet;
>> +
>> +		inet.inet_saddr = iph->saddr;
>> +		inet.inet_daddr = iph->daddr;
>> +		skb->ip_summed = CHECKSUM_NONE;
>> +		tcp_v4_send_check((struct sock *)&inet, skb);
>
> Please don't do things like this.  Making fake sockets on the stack, don't
> do it.
>
> Do other non-socket contexts compute TCP checksums this way?  Check
> netfilter or similar, see what they do.
>
> Worst case export __tcp_v4_send_check() or just duplicate it's contents
> in the tcp case here.
Indeed, it was a quick and dirty solution. I'll duplicate the relevant 
bits __tcp_v4_send_check

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ