[ovs-dev] [VLAN splinters 13/16] ofproto-dpif: Simplify invocation of send_packet().

Ethan Jackson ethan at nicira.com
Wed Nov 23 19:41:29 UTC 2011


Looks good.

Ethan

On Tue, Nov 15, 2011 at 17:17, Ben Pfaff <blp at nicira.com> wrote:
> All the callers already have the ofport handy, so they might as well just
> pass it in directly.
> ---
>  ofproto/ofproto-dpif.c |   21 +++++++++------------
>  1 files changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> index df2466d..e8c12b1 100644
> --- a/ofproto/ofproto-dpif.c
> +++ b/ofproto/ofproto-dpif.c
> @@ -483,7 +483,7 @@ static int expire(struct ofproto_dpif *);
>  static void send_netflow_active_timeouts(struct ofproto_dpif *);
>
>  /* Utilities. */
> -static int send_packet(struct ofproto_dpif *, uint32_t odp_port,
> +static int send_packet(const struct ofport_dpif *,
>                        const struct ofpbuf *packet);
>  static size_t
>  compose_sflow_action(const struct ofproto_dpif *, struct ofpbuf *odp_actions,
> @@ -1002,8 +1002,7 @@ send_bpdu_cb(struct ofpbuf *pkt, int port_num, void *ofproto_)
>             VLOG_WARN_RL(&rl, "%s: cannot send BPDU on port %d "
>                          "with unknown MAC", ofproto->up.name, port_num);
>         } else {
> -            send_packet(ofproto_dpif_cast(ofport->up.ofproto),
> -                        ofport->odp_port, pkt);
> +            send_packet(ofport, pkt);
>         }
>     }
>     ofpbuf_delete(pkt);
> @@ -1599,8 +1598,7 @@ send_pdu_cb(void *port_, const void *pdu, size_t pdu_size)
>                                  pdu_size);
>         memcpy(packet_pdu, pdu, pdu_size);
>
> -        send_packet(ofproto_dpif_cast(port->up.ofproto), port->odp_port,
> -                    &packet);
> +        send_packet(port, &packet);
>         ofpbuf_uninit(&packet);
>     } else {
>         VLOG_ERR_RL(&rl, "port %s: cannot obtain Ethernet address of iface "
> @@ -1626,8 +1624,7 @@ bundle_send_learning_packets(struct ofbundle *bundle)
>             learning_packet = bond_compose_learning_packet(bundle->bond, e->mac,
>                                                            e->vlan,
>                                                            (void **)&port);
> -            ret = send_packet(ofproto_dpif_cast(port->up.ofproto),
> -                              port->odp_port, learning_packet);
> +            ret = send_packet(port, learning_packet);
>             ofpbuf_delete(learning_packet);
>             if (ret) {
>                 error = ret;
> @@ -1914,8 +1911,7 @@ port_run(struct ofport_dpif *ofport)
>
>             ofpbuf_init(&packet, 0);
>             cfm_compose_ccm(ofport->cfm, &packet, ofport->up.opp.hw_addr);
> -            send_packet(ofproto_dpif_cast(ofport->up.ofproto),
> -                        ofport->odp_port, &packet);
> +            send_packet(ofport, &packet);
>             ofpbuf_uninit(&packet);
>         }
>
> @@ -3551,12 +3547,13 @@ rule_modify_actions(struct rule *rule_)
>     complete_operation(rule);
>  }
>
> -/* Sends 'packet' out of port 'odp_port' within 'ofproto'.
> +/* Sends 'packet' out 'ofport'.
>  * Returns 0 if successful, otherwise a positive errno value. */
>  static int
> -send_packet(struct ofproto_dpif *ofproto, uint32_t odp_port,
> -            const struct ofpbuf *packet)
> +send_packet(const struct ofport_dpif *ofport, const struct ofpbuf *packet)
>  {
> +    const struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofport->up.ofproto);
> +    uint16_t odp_port = ofport->odp_port;
>     struct ofpbuf key, odp_actions;
>     struct odputil_keybuf keybuf;
>     struct flow flow;
> --
> 1.7.4.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list