Thread (18 messages) flat view 18 messages, 4 authors, 2016-10-21

Re: [PATCH net-next v12 5/9] openvswitch: add processing of L3 packets

From: Pravin Shelar <hidden>
Date: 2016-10-19 05:13:50

On Mon, Oct 17, 2016 at 6:02 AM, Jiri Benc [off-list ref] wrote:
Support receiving, extracting flow key and sending of L3 packets (packets
without an Ethernet header).

Note that even after this patch, non-Ethernet interfaces are still not
allowed to be added to bridges. Similarly, netlink interface for sending and
receiving L3 packets to/from user space is not in place yet.

Based on previous versions by Lorand Jakab and Simon Horman.

Signed-off-by: Lorand Jakab <redacted>
Signed-off-by: Simon Horman <redacted>
Signed-off-by: Jiri Benc <redacted>
---
 net/openvswitch/datapath.c |  17 ++------
 net/openvswitch/flow.c     | 101 ++++++++++++++++++++++++++++++++++-----------
 net/openvswitch/vport.c    |  16 +++++++
 3 files changed, 96 insertions(+), 38 deletions(-)
...
quoted hunk ↗ jump to hunk
@@ -505,28 +511,35 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)

        skb_reset_mac_header(skb);

-       /* Link layer.  We are guaranteed to have at least the 14 byte Ethernet
-        * header in the linear data area.
-        */
-       eth = eth_hdr(skb);
-       ether_addr_copy(key->eth.src, eth->h_source);
-       ether_addr_copy(key->eth.dst, eth->h_dest);
+       /* Link layer. */
+       clear_vlan(key);
+       if (key->mac_proto == MAC_PROTO_NONE) {
+               if (unlikely(eth_type_vlan(skb->protocol)))
+                       return -EINVAL;

-       __skb_pull(skb, 2 * ETH_ALEN);
-       /* We are going to push all headers that we pull, so no need to
-        * update skb->csum here.
-        */
+               skb_reset_network_header(skb);
+       } else {
+               eth = eth_hdr(skb);
+               ether_addr_copy(key->eth.src, eth->h_source);
+               ether_addr_copy(key->eth.dst, eth->h_dest);

-       if (unlikely(parse_vlan(skb, key)))
-               return -ENOMEM;
+               __skb_pull(skb, 2 * ETH_ALEN);
+               /* We are going to push all headers that we pull, so no need to
+               * update skb->csum here.
+               */

-       key->eth.type = parse_ethertype(skb);
-       if (unlikely(key->eth.type == htons(0)))
-               return -ENOMEM;
+               if (unlikely(parse_vlan(skb, key)))
+                       return -ENOMEM;

-       skb_reset_network_header(skb);
+               skb->protocol = parse_ethertype(skb);
I am not sure about changing skb->protocol here.
By changing this skb loosing information about packet type. Therefore
if packet re-enters OVS (through different bridge), this packet would
look like L3 packet. function key_extract_mac_proto() would not see
TEB type packet.
quoted hunk ↗ jump to hunk
+               if (unlikely(skb->protocol == htons(0)))
+                       return -ENOMEM;
+
+               skb_reset_network_header(skb);
+               __skb_push(skb, skb->data - skb_mac_header(skb));
+       }
        skb_reset_mac_len(skb);
-       __skb_push(skb, skb->data - skb_mac_header(skb));
+       key->eth.type = skb->protocol;

        /* Network layer. */
        if (key->eth.type == htons(ETH_P_IP)) {
@@ -721,6 +734,20 @@ int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key)
        return key_extract(skb, key);
 }

+static u8 key_extract_mac_proto(struct sk_buff *skb)
+{
+       switch (skb->dev->type) {
+       case ARPHRD_ETHER:
+               return MAC_PROTO_ETHERNET;
+       case ARPHRD_NONE:
+               if (skb->protocol == htons(ETH_P_TEB))
+                       return MAC_PROTO_ETHERNET;
+               return MAC_PROTO_NONE;
+       }
+       WARN_ON_ONCE(1);
+       return MAC_PROTO_ETHERNET;
+}
+
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help