netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* sendmsg() and vlan tags
@ 2013-07-26 21:30 Ani Sinha
  2013-07-31  0:29 ` Ani Sinha
  0 siblings, 1 reply; 4+ messages in thread
From: Ani Sinha @ 2013-07-26 21:30 UTC (permalink / raw)
  To: netdev

Hi folks,

We know that (since Linux 3.0) on raw sockets, the recvmsg() api
returns the vlan tag information of the packet in the packet aux data.
I looked at the kernel code and it seems on the TX side, in sendmsg(),
we do not accept the vlan tag data from userland for a raw packet. So
if the userland sends a raw packet using sendmsg() with vlan tag
information in aux data, it will be discarded.

Is my analysis correct?

Cheers,
Ani

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sendmsg() and vlan tags
  2013-07-26 21:30 sendmsg() and vlan tags Ani Sinha
@ 2013-07-31  0:29 ` Ani Sinha
  2013-07-31  0:56   ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Ani Sinha @ 2013-07-31  0:29 UTC (permalink / raw)
  To: netdev

hello folks.

Can anyone please shed lights on this?

thanks,
ani


On Fri, Jul 26, 2013 at 2:30 PM, Ani Sinha <ani@aristanetworks.com> wrote:
> Hi folks,
>
> We know that (since Linux 3.0) on raw sockets, the recvmsg() api
> returns the vlan tag information of the packet in the packet aux data.
> I looked at the kernel code and it seems on the TX side, in sendmsg(),
> we do not accept the vlan tag data from userland for a raw packet. So
> if the userland sends a raw packet using sendmsg() with vlan tag
> information in aux data, it will be discarded.
>
> Is my analysis correct?
>
> Cheers,
> Ani



-- 
Ani

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sendmsg() and vlan tags
  2013-07-31  0:29 ` Ani Sinha
@ 2013-07-31  0:56   ` Eric Dumazet
  2013-07-31 21:01     ` Ani Sinha
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2013-07-31  0:56 UTC (permalink / raw)
  To: Ani Sinha; +Cc: netdev

On Tue, 2013-07-30 at 17:29 -0700, Ani Sinha wrote:
> hello folks.
> 
> Can anyone please shed lights on this?
> 
> thanks,
> ani
> 
> 
> On Fri, Jul 26, 2013 at 2:30 PM, Ani Sinha <ani@aristanetworks.com> wrote:
> > Hi folks,
> >
> > We know that (since Linux 3.0) on raw sockets, the recvmsg() api
> > returns the vlan tag information of the packet in the packet aux data.
> > I looked at the kernel code and it seems on the TX side, in sendmsg(),
> > we do not accept the vlan tag data from userland for a raw packet. So
> > if the userland sends a raw packet using sendmsg() with vlan tag
> > information in aux data, it will be discarded.


What is the vlan tag information value in aux data ?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sendmsg() and vlan tags
  2013-07-31  0:56   ` Eric Dumazet
@ 2013-07-31 21:01     ` Ani Sinha
  0 siblings, 0 replies; 4+ messages in thread
From: Ani Sinha @ 2013-07-31 21:01 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev

On Tue, Jul 30, 2013 at 5:56 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Tue, 2013-07-30 at 17:29 -0700, Ani Sinha wrote:
>> hello folks.
>>
>> Can anyone please shed lights on this?
>>
>> thanks,
>> ani
>>
>>
>> On Fri, Jul 26, 2013 at 2:30 PM, Ani Sinha <ani@aristanetworks.com> wrote:
>> > Hi folks,
>> >
>> > We know that (since Linux 3.0) on raw sockets, the recvmsg() api
>> > returns the vlan tag information of the packet in the packet aux data.
>> > I looked at the kernel code and it seems on the TX side, in sendmsg(),
>> > we do not accept the vlan tag data from userland for a raw packet. So
>> > if the userland sends a raw packet using sendmsg() with vlan tag
>> > information in aux data, it will be discarded.
>
>
> What is the vlan tag information value in aux data ?
>

It populates tp_vlan_tci field in the aux data (tpacket_auxdata
structure). Specifically, it gets the packet vlan tag ID and vlan
priority fields (PCP) from the skb.

In net/packet/af_packet.c :


a3bcc23e        (Ben Greear     2011-06-01 06:49:10 +0000       2822)
         if (vlan_tx_tag_present(skb)) {
a3bcc23e        (Ben Greear     2011-06-01 06:49:10 +0000       2823)
                 aux.tp_vlan_tci = vlan_tx_tag_get(skb);
a3bcc23e        (Ben Greear     2011-06-01 06:49:10 +0000       2824)
                 aux.tp_status |= TP_STATUS_VLAN_VALID;
a3bcc23e        (Ben Greear     2011-06-01 06:49:10 +0000       2825)
         } else {
a3bcc23e        (Ben Greear     2011-06-01 06:49:10 +0000       2826)
                 aux.tp_vlan_tci = 0;
a3bcc23e        (Ben Greear     2011-06-01 06:49:10 +0000       2827)
         }


The question is, on TX, can the user populate these values in the aux
data of a raw packet and do a sendmsg(). Will the kernel retain these
values. It looks like it does not.

-- 
Ani

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-31 21:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-26 21:30 sendmsg() and vlan tags Ani Sinha
2013-07-31  0:29 ` Ani Sinha
2013-07-31  0:56   ` Eric Dumazet
2013-07-31 21:01     ` Ani Sinha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).