flow.c (d3e1101c9b75574e68380b5cb10c9395fd8855de) flow.c (e5c5d22e8dcf7c2d430336cbf8e180bd38e8daf1)
1/*
2 * Copyright (c) 2007-2011 Nicira, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 2 of the GNU General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but

--- 452 unchanged lines hidden (view full) ---

461 __be16 ethertype;
462 };
463 struct llc_snap_hdr *llc;
464 __be16 proto;
465
466 proto = *(__be16 *) skb->data;
467 __skb_pull(skb, sizeof(__be16));
468
1/*
2 * Copyright (c) 2007-2011 Nicira, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 2 of the GNU General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but

--- 452 unchanged lines hidden (view full) ---

461 __be16 ethertype;
462 };
463 struct llc_snap_hdr *llc;
464 __be16 proto;
465
466 proto = *(__be16 *) skb->data;
467 __skb_pull(skb, sizeof(__be16));
468
469 if (ntohs(proto) >= 1536)
469 if (ntohs(proto) >= ETH_P_802_3_MIN)
470 return proto;
471
472 if (skb->len < sizeof(struct llc_snap_hdr))
473 return htons(ETH_P_802_2);
474
475 if (unlikely(!pskb_may_pull(skb, sizeof(struct llc_snap_hdr))))
476 return htons(0);
477
478 llc = (struct llc_snap_hdr *) skb->data;
479 if (llc->dsap != LLC_SAP_SNAP ||
480 llc->ssap != LLC_SAP_SNAP ||
481 (llc->oui[0] | llc->oui[1] | llc->oui[2]) != 0)
482 return htons(ETH_P_802_2);
483
484 __skb_pull(skb, sizeof(struct llc_snap_hdr));
485
470 return proto;
471
472 if (skb->len < sizeof(struct llc_snap_hdr))
473 return htons(ETH_P_802_2);
474
475 if (unlikely(!pskb_may_pull(skb, sizeof(struct llc_snap_hdr))))
476 return htons(0);
477
478 llc = (struct llc_snap_hdr *) skb->data;
479 if (llc->dsap != LLC_SAP_SNAP ||
480 llc->ssap != LLC_SAP_SNAP ||
481 (llc->oui[0] | llc->oui[1] | llc->oui[2]) != 0)
482 return htons(ETH_P_802_2);
483
484 __skb_pull(skb, sizeof(struct llc_snap_hdr));
485
486 if (ntohs(llc->ethertype) >= 1536)
486 if (ntohs(llc->ethertype) >= ETH_P_802_3_MIN)
487 return llc->ethertype;
488
489 return htons(ETH_P_802_2);
490}
491
492static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,
493 int *key_lenp, int nh_len)
494{

--- 295 unchanged lines hidden (view full) ---

790
791 head = find_bucket(table, flow->hash);
792 hlist_add_head_rcu(&flow->hash_node[table->node_ver], head);
793 table->count++;
794}
795
796void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow)
797{
487 return llc->ethertype;
488
489 return htons(ETH_P_802_2);
490}
491
492static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,
493 int *key_lenp, int nh_len)
494{

--- 295 unchanged lines hidden (view full) ---

790
791 head = find_bucket(table, flow->hash);
792 hlist_add_head_rcu(&flow->hash_node[table->node_ver], head);
793 table->count++;
794}
795
796void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow)
797{
798 BUG_ON(table->count == 0);
799 hlist_del_rcu(&flow->hash_node[table->node_ver]);
800 table->count--;
798 hlist_del_rcu(&flow->hash_node[table->node_ver]);
799 table->count--;
800 BUG_ON(table->count < 0);
801}
802
803/* The size of the argument for each %OVS_KEY_ATTR_* Netlink attribute. */
804const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = {
805 [OVS_KEY_ATTR_ENCAP] = -1,
806 [OVS_KEY_ATTR_PRIORITY] = sizeof(u32),
807 [OVS_KEY_ATTR_IN_PORT] = sizeof(u32),
808 [OVS_KEY_ATTR_SKB_MARK] = sizeof(u32),

--- 224 unchanged lines hidden (view full) ---

1033 return 0;
1034 } else {
1035 return -EINVAL;
1036 }
1037 }
1038
1039 if (attrs & (1 << OVS_KEY_ATTR_ETHERTYPE)) {
1040 swkey->eth.type = nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]);
801}
802
803/* The size of the argument for each %OVS_KEY_ATTR_* Netlink attribute. */
804const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = {
805 [OVS_KEY_ATTR_ENCAP] = -1,
806 [OVS_KEY_ATTR_PRIORITY] = sizeof(u32),
807 [OVS_KEY_ATTR_IN_PORT] = sizeof(u32),
808 [OVS_KEY_ATTR_SKB_MARK] = sizeof(u32),

--- 224 unchanged lines hidden (view full) ---

1033 return 0;
1034 } else {
1035 return -EINVAL;
1036 }
1037 }
1038
1039 if (attrs & (1 << OVS_KEY_ATTR_ETHERTYPE)) {
1040 swkey->eth.type = nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]);
1041 if (ntohs(swkey->eth.type) < 1536)
1041 if (ntohs(swkey->eth.type) < ETH_P_802_3_MIN)
1042 return -EINVAL;
1043 attrs &= ~(1 << OVS_KEY_ATTR_ETHERTYPE);
1044 } else {
1045 swkey->eth.type = htons(ETH_P_802_2);
1046 }
1047
1048 if (swkey->eth.type == htons(ETH_P_IP)) {
1049 const struct ovs_key_ipv4 *ipv4_key;

--- 308 unchanged lines hidden ---
1042 return -EINVAL;
1043 attrs &= ~(1 << OVS_KEY_ATTR_ETHERTYPE);
1044 } else {
1045 swkey->eth.type = htons(ETH_P_802_2);
1046 }
1047
1048 if (swkey->eth.type == htons(ETH_P_IP)) {
1049 const struct ovs_key_ipv4 *ipv4_key;

--- 308 unchanged lines hidden ---