From: Alexander Duyck <alexander.h.du...@redhat.com>

Replace "ntohs(proto) >= ETH_P_802_3_MIN" w/ eth_proto_is_802_3(proto).

Backport of upstream commit 6713fc9b8fa33444aa000f0f31076f6a859ccb34:
"openvswitch: Use eth_proto_is_802_3"

Signed-off-by: Alexander Duyck <alexander.h.du...@redhat.com>
Signed-off-by: David S. Miller <da...@davemloft.net>
Signed-off-by: Joe Stringer <joestrin...@nicira.com>
---
 datapath/datapath.c     | 2 +-
 datapath/flow.c         | 4 ++--
 datapath/flow_netlink.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index 13b2696..3d12bd9 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -570,7 +570,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, 
struct genl_info *info)
         * call to eth_type_trans(), but it assumes there's a sending
         * device, which we may not have.
         */
-       if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN)
+       if (eth_proto_is_802_3(eth->h_proto))
                packet->protocol = eth->h_proto;
        else
                packet->protocol = htons(ETH_P_802_2);
diff --git a/datapath/flow.c b/datapath/flow.c
index 699d62c..a7a2063 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -331,7 +331,7 @@ static __be16 parse_ethertype(struct sk_buff *skb)
        proto = *(__be16 *) skb->data;
        __skb_pull(skb, sizeof(__be16));
 
-       if (ntohs(proto) >= ETH_P_802_3_MIN)
+       if (eth_proto_is_802_3(proto))
                return proto;
 
        if (skb->len < sizeof(struct llc_snap_hdr))
@@ -348,7 +348,7 @@ static __be16 parse_ethertype(struct sk_buff *skb)
 
        __skb_pull(skb, sizeof(struct llc_snap_hdr));
 
-       if (ntohs(llc->ethertype) >= ETH_P_802_3_MIN)
+       if (eth_proto_is_802_3(llc->ethertype))
                return llc->ethertype;
 
        return htons(ETH_P_802_2);
diff --git a/datapath/flow_netlink.c b/datapath/flow_netlink.c
index 997da19..9115d15 100644
--- a/datapath/flow_netlink.c
+++ b/datapath/flow_netlink.c
@@ -814,7 +814,7 @@ static int ovs_key_from_nlattrs(struct sw_flow_match 
*match, u64 attrs,
                if (is_mask) {
                        /* Always exact match EtherType. */
                        eth_type = htons(0xffff);
-               } else if (ntohs(eth_type) < ETH_P_802_3_MIN) {
+               } else if (!eth_proto_is_802_3(eth_type)) {
                        OVS_NLERR(log, "EtherType %x is less than min %x",
                                  ntohs(eth_type), ETH_P_802_3_MIN);
                        return -EINVAL;
-- 
2.1.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to