On Wed, Feb 8, 2017 at 7:34 AM, Sowmini Varadhan
<sowmini.varad...@oracle.com> wrote:
> On (02/07/17 15:57), Willem de Bruijn wrote:
>> @@ -2816,8 +2816,9 @@ static int packet_snd(struct socket *sock, struct 
>> msghdr *msg, size_t len)
>>       err = -ENOBUFS;
>>       hlen = LL_RESERVED_SPACE(dev);
>>       tlen = dev->needed_tailroom;
>> -     skb = packet_alloc_skb(sk, hlen + tlen, hlen, len,
>> -                            __virtio16_to_cpu(vio_le(), vnet_hdr.hdr_len),
>> +     linear = __virtio16_to_cpu(vio_le(), vnet_hdr.hdr_len);
>> +     linear = max(linear, min_t(int, len, dev->hard_header_len));
>> +     skb = packet_alloc_skb(sk, hlen + tlen, hlen, len, linear,
>>                              msg->msg_flags & MSG_DONTWAIT, &err);
>
> do we need a similar check in packet_sendsmg_spkt (even if it
> is deprecated, would be better to get it to align with packet_snd?)

That path does not need this check, because it does not support
large packets and always allocates the entire packet as linear.

> Also tpacket_fill_skb should ensure that copylen is set up like
> the code above?

Do you mean the difference that it unconditionally pulls
hard_header_len, optionally with zero padding, whereas this new
path can check against new min_header_len and thus allows
packets shorter than hard_header_len?

Reply via email to