[ovs-dev] [tunnel 06/11] packets: Create global helper is_ip_any().

Ethan Jackson ethan at nicira.com
Tue Jan 29 01:06:04 UTC 2013


Thanks this looks good, I've folded it in.

Ethan

On Mon, Jan 28, 2013 at 11:10 AM, Ben Pfaff <blp at nicira.com> wrote:
> On Sun, Jan 27, 2013 at 04:58:07PM -0800, Ethan Jackson wrote:
>> Used outside of meta-flow in future patches.
>>
>> Signed-off-by: Ethan Jackson <ethan at nicira.com>
>
> There are some existing potential users you could throw in:
>
> diff --git a/lib/match.c b/lib/match.c
> index f1bf63c..bedb1a1 100644
> --- a/lib/match.c
> +++ b/lib/match.c
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
> + * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
>   *
>   * Licensed under the Apache License, Version 2.0 (the "License");
>   * you may not use this file except in compliance with the License.
> @@ -106,8 +106,7 @@ match_wc_init(struct match *match, const struct flow *flow)
>          memset(&wc->masks.arp_tha, 0xff, sizeof wc->masks.arp_tha);
>      }
>
> -    if (flow->dl_type == htons(ETH_TYPE_IPV6) ||
> -        flow->dl_type == htons(ETH_TYPE_IP)) {
> +    if (is_ip_any(flow)) {
>          memset(&wc->masks.nw_tos, 0xff, sizeof wc->masks.nw_tos);
>          memset(&wc->masks.nw_ttl, 0xff, sizeof wc->masks.nw_ttl);
>      }
> diff --git a/lib/odp-util.c b/lib/odp-util.c
> index 96a9523..6767b08 100644
> --- a/lib/odp-util.c
> +++ b/lib/odp-util.c
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
> + * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
>   *
>   * Licensed under the Apache License, Version 2.0 (the "License");
>   * you may not use this file except in compliance with the License.
> @@ -1526,10 +1526,7 @@ odp_flow_key_from_flow(struct ofpbuf *buf, const struct flow *flow,
>          memcpy(arp_key->arp_tha, flow->arp_tha, ETH_ADDR_LEN);
>      }
>
> -    if ((flow->dl_type == htons(ETH_TYPE_IP)
> -         || flow->dl_type == htons(ETH_TYPE_IPV6))
> -        && !(flow->nw_frag & FLOW_NW_FRAG_LATER)) {
> -
> +    if (is_ip_any(flow) && !(flow->nw_frag & FLOW_NW_FRAG_LATER)) {
>          if (flow->nw_proto == IPPROTO_TCP) {
>              struct ovs_key_tcp *tcp_key;
>
> @@ -1790,8 +1787,7 @@ parse_l3_onward(const struct nlattr *attrs[OVS_KEY_ATTR_MAX + 1],
>      }
>
>      if (flow->nw_proto == IPPROTO_TCP
> -        && (flow->dl_type == htons(ETH_TYPE_IP) ||
> -            flow->dl_type == htons(ETH_TYPE_IPV6))
> +        && is_ip_any(flow)
>          && !(flow->nw_frag & FLOW_NW_FRAG_LATER)) {
>          expected_attrs |= UINT64_C(1) << OVS_KEY_ATTR_TCP;
>          if (present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_TCP)) {
> @@ -1802,8 +1798,7 @@ parse_l3_onward(const struct nlattr *attrs[OVS_KEY_ATTR_MAX + 1],
>              flow->tp_dst = tcp_key->tcp_dst;
>          }
>      } else if (flow->nw_proto == IPPROTO_UDP
> -               && (flow->dl_type == htons(ETH_TYPE_IP) ||
> -                   flow->dl_type == htons(ETH_TYPE_IPV6))
> +               && is_ip_any(flow)
>                 && !(flow->nw_frag & FLOW_NW_FRAG_LATER)) {
>          expected_attrs |= UINT64_C(1) << OVS_KEY_ATTR_UDP;
>          if (present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_UDP)) {
> diff --git a/lib/packets.c b/lib/packets.c
> index 73dfcdc..fa73282 100644
> --- a/lib/packets.c
> +++ b/lib/packets.c
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
> + * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
>   *
>   * Licensed under the Apache License, Version 2.0 (the "License");
>   * you may not use this file except in compliance with the License.
> @@ -710,9 +710,7 @@ packet_set_udp_port(struct ofpbuf *packet, ovs_be16 src, ovs_be16 dst)
>  uint8_t
>  packet_get_tcp_flags(const struct ofpbuf *packet, const struct flow *flow)
>  {
> -    if ((flow->dl_type == htons(ETH_TYPE_IP) ||
> -         flow->dl_type == htons(ETH_TYPE_IPV6)) &&
> -        flow->nw_proto == IPPROTO_TCP && packet->l7) {
> +    if (is_ip_any(flow) && flow->nw_proto == IPPROTO_TCP && packet->l7) {
>          const struct tcp_header *tcp = packet->l4;
>          return TCP_FLAGS(tcp->tcp_ctl);
>      } else {



More information about the dev mailing list