* [PATCH net-next] Enhanced skb_mpls_pop to update ethertype of the packet in all the cases when an ethernet header is present is the packet.
@ 2019-11-21 12:23 Martin Varghese
2019-11-22 2:22 ` Pravin Shelar
0 siblings, 1 reply; 4+ messages in thread
From: Martin Varghese @ 2019-11-21 12:23 UTC (permalink / raw)
To: netdev, pshelar, davem, jhs, xiyou.wangcong, jiri, martin.varghese
From: Martin Varghese <martin.varghese@nokia.com>
The skb_mpls_pop was not updating ethertype of an ethernet packet if the
packet was originally received from a non ARPHRD_ETHER device.
In the below OVS data path flow, since the device corresponding to port 7
is an l3 device (ARPHRD_NONE) the skb_mpls_pop function does not update
the ethertype of the packet even though the previous push_eth action had
added an ethernet header to the packet.
recirc_id(0),in_port(7),eth_type(0x8847),
mpls(label=12/0xfffff,tc=0/0,ttl=0/0x0,bos=1/1),
actions:push_eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00),
pop_mpls(eth_type=0x800),4
Signed-off-by: Martin Varghese <martin.varghese@nokia.com>
---
include/linux/skbuff.h | 3 ++-
net/core/skbuff.c | 8 +++++---
net/openvswitch/actions.c | 2 +-
net/sched/act_mpls.c | 2 +-
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index dfe02b6..70204b9 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3530,7 +3530,8 @@ int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,
int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci);
int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
int mac_len);
-int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len);
+int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
+ bool ethernet);
int skb_mpls_update_lse(struct sk_buff *skb, __be32 mpls_lse);
int skb_mpls_dec_ttl(struct sk_buff *skb);
struct sk_buff *pskb_extract(struct sk_buff *skb, int off, int to_copy,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 867e61d..8ac377d 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5529,12 +5529,14 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
* @skb: buffer
* @next_proto: ethertype of header after popped MPLS header
* @mac_len: length of the MAC header
- *
+ * @ethernet: flag to indicate if ethernet header is present in packet
+ * ignored for device type ARPHRD_ETHER
* Expects skb->data at mac header.
*
* Returns 0 on success, -errno otherwise.
*/
-int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)
+int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
+ bool ethernet)
{
int err;
@@ -5553,7 +5555,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)
skb_reset_mac_header(skb);
skb_set_network_header(skb, mac_len);
- if (skb->dev && skb->dev->type == ARPHRD_ETHER) {
+ if ((skb->dev && skb->dev->type == ARPHRD_ETHER) || ethernet) {
struct ethhdr *hdr;
/* use mpls_hdr() to get ethertype to account for VLANs. */
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 12936c1..9e5d274 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -179,7 +179,7 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key,
{
int err;
- err = skb_mpls_pop(skb, ethertype, skb->mac_len);
+ err = skb_mpls_pop(skb, ethertype, skb->mac_len, true);
if (err)
return err;
diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c
index 4d8c822..5fa39fc 100644
--- a/net/sched/act_mpls.c
+++ b/net/sched/act_mpls.c
@@ -76,7 +76,7 @@ static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a,
switch (p->tcfm_action) {
case TCA_MPLS_ACT_POP:
- if (skb_mpls_pop(skb, p->tcfm_proto, mac_len))
+ if (skb_mpls_pop(skb, p->tcfm_proto, mac_len, false))
goto drop;
break;
case TCA_MPLS_ACT_PUSH:
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] Enhanced skb_mpls_pop to update ethertype of the packet in all the cases when an ethernet header is present is the packet.
2019-11-21 12:23 [PATCH net-next] Enhanced skb_mpls_pop to update ethertype of the packet in all the cases when an ethernet header is present is the packet Martin Varghese
@ 2019-11-22 2:22 ` Pravin Shelar
2019-11-22 5:12 ` Martin Varghese
0 siblings, 1 reply; 4+ messages in thread
From: Pravin Shelar @ 2019-11-22 2:22 UTC (permalink / raw)
To: Martin Varghese
Cc: Linux Kernel Network Developers, David S. Miller,
Jamal Hadi Salim, Cong Wang, Jiri Pirko, Varghese,
Martin (Nokia - IN/Bangalore)
On Thu, Nov 21, 2019 at 4:23 AM Martin Varghese
<martinvarghesenokia@gmail.com> wrote:
>
> From: Martin Varghese <martin.varghese@nokia.com>
>
> The skb_mpls_pop was not updating ethertype of an ethernet packet if the
> packet was originally received from a non ARPHRD_ETHER device.
>
> In the below OVS data path flow, since the device corresponding to port 7
> is an l3 device (ARPHRD_NONE) the skb_mpls_pop function does not update
> the ethertype of the packet even though the previous push_eth action had
> added an ethernet header to the packet.
>
> recirc_id(0),in_port(7),eth_type(0x8847),
> mpls(label=12/0xfffff,tc=0/0,ttl=0/0x0,bos=1/1),
> actions:push_eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00),
> pop_mpls(eth_type=0x800),4
>
> Signed-off-by: Martin Varghese <martin.varghese@nokia.com>
> ---
> include/linux/skbuff.h | 3 ++-
> net/core/skbuff.c | 8 +++++---
> net/openvswitch/actions.c | 2 +-
> net/sched/act_mpls.c | 2 +-
> 4 files changed, 9 insertions(+), 6 deletions(-)
>
...
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 867e61d..8ac377d 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -5529,12 +5529,14 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
> * @skb: buffer
> * @next_proto: ethertype of header after popped MPLS header
> * @mac_len: length of the MAC header
> - *
> + * @ethernet: flag to indicate if ethernet header is present in packet
> + * ignored for device type ARPHRD_ETHER
> * Expects skb->data at mac header.
> *
> * Returns 0 on success, -errno otherwise.
> */
> -int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)
> +int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
> + bool ethernet)
> {
> int err;
>
> @@ -5553,7 +5555,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)
> skb_reset_mac_header(skb);
> skb_set_network_header(skb, mac_len);
>
> - if (skb->dev && skb->dev->type == ARPHRD_ETHER) {
> + if ((skb->dev && skb->dev->type == ARPHRD_ETHER) || ethernet) {
> struct ethhdr *hdr;
Lets move the dev-type check to caller. That would also avoid one more
argument to this function.
>
> /* use mpls_hdr() to get ethertype to account for VLANs. */
> diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
> index 12936c1..9e5d274 100644
> --- a/net/openvswitch/actions.c
> +++ b/net/openvswitch/actions.c
> @@ -179,7 +179,7 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key,
> {
> int err;
>
> - err = skb_mpls_pop(skb, ethertype, skb->mac_len);
> + err = skb_mpls_pop(skb, ethertype, skb->mac_len, true);
> if (err)
OVS supports L3 packets, you need to check flow key for type of packet
(ovs_key_mac_proto()) under process.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] Enhanced skb_mpls_pop to update ethertype of the packet in all the cases when an ethernet header is present is the packet.
2019-11-22 2:22 ` Pravin Shelar
@ 2019-11-22 5:12 ` Martin Varghese
2019-11-22 6:33 ` Pravin Shelar
0 siblings, 1 reply; 4+ messages in thread
From: Martin Varghese @ 2019-11-22 5:12 UTC (permalink / raw)
To: Pravin Shelar
Cc: Linux Kernel Network Developers, David S. Miller,
Jamal Hadi Salim, Cong Wang, Jiri Pirko, Varghese,
Martin (Nokia - IN/Bangalore)
On Thu, Nov 21, 2019 at 06:22:29PM -0800, Pravin Shelar wrote:
> On Thu, Nov 21, 2019 at 4:23 AM Martin Varghese
> <martinvarghesenokia@gmail.com> wrote:
> >
> > From: Martin Varghese <martin.varghese@nokia.com>
> >
> > The skb_mpls_pop was not updating ethertype of an ethernet packet if the
> > packet was originally received from a non ARPHRD_ETHER device.
> >
> > In the below OVS data path flow, since the device corresponding to port 7
> > is an l3 device (ARPHRD_NONE) the skb_mpls_pop function does not update
> > the ethertype of the packet even though the previous push_eth action had
> > added an ethernet header to the packet.
> >
> > recirc_id(0),in_port(7),eth_type(0x8847),
> > mpls(label=12/0xfffff,tc=0/0,ttl=0/0x0,bos=1/1),
> > actions:push_eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00),
> > pop_mpls(eth_type=0x800),4
> >
> > Signed-off-by: Martin Varghese <martin.varghese@nokia.com>
> > ---
> > include/linux/skbuff.h | 3 ++-
> > net/core/skbuff.c | 8 +++++---
> > net/openvswitch/actions.c | 2 +-
> > net/sched/act_mpls.c | 2 +-
> > 4 files changed, 9 insertions(+), 6 deletions(-)
> >
> ...
> > diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> > index 867e61d..8ac377d 100644
> > --- a/net/core/skbuff.c
> > +++ b/net/core/skbuff.c
> > @@ -5529,12 +5529,14 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
> > * @skb: buffer
> > * @next_proto: ethertype of header after popped MPLS header
> > * @mac_len: length of the MAC header
> > - *
> > + * @ethernet: flag to indicate if ethernet header is present in packet
> > + * ignored for device type ARPHRD_ETHER
> > * Expects skb->data at mac header.
> > *
> > * Returns 0 on success, -errno otherwise.
> > */
> > -int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)
> > +int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
> > + bool ethernet)
> > {
> > int err;
> >
> > @@ -5553,7 +5555,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)
> > skb_reset_mac_header(skb);
> > skb_set_network_header(skb, mac_len);
> >
> > - if (skb->dev && skb->dev->type == ARPHRD_ETHER) {
> > + if ((skb->dev && skb->dev->type == ARPHRD_ETHER) || ethernet) {
> > struct ethhdr *hdr;
> Lets move the dev-type check to caller. That would also avoid one more
> argument to this function.
To have only the ethernet flag check in the function like below ?
If (ethernet) {
/*pseudo*/ Update ethertype
}
And pass the flag to the function considering the device type
Fo example in case of tc.
if (skb_mpls_pop(skb, p->tcfm_proto, mac_len,
(skb->dev && skb->dev->type == ARPHRD_ETHER))).
But how do we avoid an argument here ? I am missing anything ?
>
> >
> > /* use mpls_hdr() to get ethertype to account for VLANs. */
> > diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
> > index 12936c1..9e5d274 100644
> > --- a/net/openvswitch/actions.c
> > +++ b/net/openvswitch/actions.c
> > @@ -179,7 +179,7 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key,
> > {
> > int err;
> >
> > - err = skb_mpls_pop(skb, ethertype, skb->mac_len);
> > + err = skb_mpls_pop(skb, ethertype, skb->mac_len, true);
> > if (err)
> OVS supports L3 packets, you need to check flow key for type of packet
> (ovs_key_mac_proto()) under process.
Yes I missed that.
err = skb_mpls_pop(skb, ethertype, skb->mac_len, ovs_key_mac_proto())); ?
or
err = skb_mpls_pop(skb, ethertype, skb->mac_len, key->mac_proto = MAC_PROTO_ETHERNET)
I assume both acheives the same
Thanks for reviewing
Martin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] Enhanced skb_mpls_pop to update ethertype of the packet in all the cases when an ethernet header is present is the packet.
2019-11-22 5:12 ` Martin Varghese
@ 2019-11-22 6:33 ` Pravin Shelar
0 siblings, 0 replies; 4+ messages in thread
From: Pravin Shelar @ 2019-11-22 6:33 UTC (permalink / raw)
To: Martin Varghese
Cc: Linux Kernel Network Developers, David S. Miller,
Jamal Hadi Salim, Cong Wang, Jiri Pirko, Varghese,
Martin (Nokia - IN/Bangalore)
On Thu, Nov 21, 2019 at 9:13 PM Martin Varghese
<martinvarghesenokia@gmail.com> wrote:
>
> On Thu, Nov 21, 2019 at 06:22:29PM -0800, Pravin Shelar wrote:
> > On Thu, Nov 21, 2019 at 4:23 AM Martin Varghese
> > <martinvarghesenokia@gmail.com> wrote:
> > >
> > > From: Martin Varghese <martin.varghese@nokia.com>
> > >
> > > The skb_mpls_pop was not updating ethertype of an ethernet packet if the
> > > packet was originally received from a non ARPHRD_ETHER device.
> > >
> > > In the below OVS data path flow, since the device corresponding to port 7
> > > is an l3 device (ARPHRD_NONE) the skb_mpls_pop function does not update
> > > the ethertype of the packet even though the previous push_eth action had
> > > added an ethernet header to the packet.
> > >
> > > recirc_id(0),in_port(7),eth_type(0x8847),
> > > mpls(label=12/0xfffff,tc=0/0,ttl=0/0x0,bos=1/1),
> > > actions:push_eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00),
> > > pop_mpls(eth_type=0x800),4
> > >
> > > Signed-off-by: Martin Varghese <martin.varghese@nokia.com>
> > > ---
> > > include/linux/skbuff.h | 3 ++-
> > > net/core/skbuff.c | 8 +++++---
> > > net/openvswitch/actions.c | 2 +-
> > > net/sched/act_mpls.c | 2 +-
> > > 4 files changed, 9 insertions(+), 6 deletions(-)
> > >
> > ...
> > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> > > index 867e61d..8ac377d 100644
> > > --- a/net/core/skbuff.c
> > > +++ b/net/core/skbuff.c
> > > @@ -5529,12 +5529,14 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
> > > * @skb: buffer
> > > * @next_proto: ethertype of header after popped MPLS header
> > > * @mac_len: length of the MAC header
> > > - *
> > > + * @ethernet: flag to indicate if ethernet header is present in packet
> > > + * ignored for device type ARPHRD_ETHER
> > > * Expects skb->data at mac header.
> > > *
> > > * Returns 0 on success, -errno otherwise.
> > > */
> > > -int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)
> > > +int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
> > > + bool ethernet)
> > > {
> > > int err;
> > >
> > > @@ -5553,7 +5555,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)
> > > skb_reset_mac_header(skb);
> > > skb_set_network_header(skb, mac_len);
> > >
> > > - if (skb->dev && skb->dev->type == ARPHRD_ETHER) {
> > > + if ((skb->dev && skb->dev->type == ARPHRD_ETHER) || ethernet) {
> > > struct ethhdr *hdr;
> > Lets move the dev-type check to caller. That would also avoid one more
> > argument to this function.
>
>
> To have only the ethernet flag check in the function like below ?
> If (ethernet) {
> /*pseudo*/ Update ethertype
> }
> And pass the flag to the function considering the device type
> Fo example in case of tc.
>
> if (skb_mpls_pop(skb, p->tcfm_proto, mac_len,
> (skb->dev && skb->dev->type == ARPHRD_ETHER))).
>
>
> But how do we avoid an argument here ? I am missing anything ?
Right, I wanted to say new predicate can be eliminated.
> >
> > >
> > > /* use mpls_hdr() to get ethertype to account for VLANs. */
> > > diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
> > > index 12936c1..9e5d274 100644
> > > --- a/net/openvswitch/actions.c
> > > +++ b/net/openvswitch/actions.c
> > > @@ -179,7 +179,7 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key,
> > > {
> > > int err;
> > >
> > > - err = skb_mpls_pop(skb, ethertype, skb->mac_len);
> > > + err = skb_mpls_pop(skb, ethertype, skb->mac_len, true);
> > > if (err)
> > OVS supports L3 packets, you need to check flow key for type of packet
> > (ovs_key_mac_proto()) under process.
>
>
> Yes I missed that.
> err = skb_mpls_pop(skb, ethertype, skb->mac_len, ovs_key_mac_proto())); ?
> or
> err = skb_mpls_pop(skb, ethertype, skb->mac_len, key->mac_proto = MAC_PROTO_ETHERNET)
I like the second which is more explicit.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-22 6:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-21 12:23 [PATCH net-next] Enhanced skb_mpls_pop to update ethertype of the packet in all the cases when an ethernet header is present is the packet Martin Varghese
2019-11-22 2:22 ` Pravin Shelar
2019-11-22 5:12 ` Martin Varghese
2019-11-22 6:33 ` Pravin Shelar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.