Skip to content

Commit

Permalink
openvswitch: Use eth_proto_is_802_3
Browse files Browse the repository at this point in the history
Replace "ntohs(proto) >= ETH_P_802_3_MIN" w/ eth_proto_is_802_3(proto).

Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Alexander Duyck authored and David S. Miller committed May 5, 2015
1 parent d181ddc commit 6713fc9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion net/openvswitch/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
/* Normally, setting the skb 'protocol' field would be handled by a
* 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);
Expand Down
4 changes: 2 additions & 2 deletions net/openvswitch/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,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))
Expand All @@ -349,7 +349,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);
Expand Down
2 changes: 1 addition & 1 deletion net/openvswitch/flow_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,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;
Expand Down

0 comments on commit 6713fc9

Please sign in to comment.