No subject


Thu Mar 8 22:38:05 UTC 2012


1) wildcards
2) exact-match with no matching flow.

rule_make_action() will construct for
1) exact-match with matching flow

But in handle_odp_miss_msg(), rule_make_actions() is called this way,
seems for wildcard as well:

    if (rule->cr.wc.wildcards) {  <=3D=3D=3D so called for wildcard as well=
???
        rule =3D rule_create_subrule(p, rule, &flow);
        rule_make_actions(p, rule, packet);
    } else {
        if (!rule->may_install) {
            /* The rule is not installable, that is, we need to process eve=
ry
             * packet, so process the current packet and set its actions in=
to
             * 'subrule'. */
            rule_make_actions(p, rule, packet);
        } else {
            /* XXX revalidate rule if it needs it */
        }
    }

That is why I am confused. Your clarification is appreciated!

Thanks!
Yimin


On Tue, Jun 5, 2012 at 10:44 AM, YIMIN CHEN <ymchen.nbzj at gmail.com> wrote:
> Hi,
>
> Sorry to bother you again!
>
> I am working on openvswitch 1.1.0pre2 package, and trying to
> understand the logic in handle_odp_miss_msg() in ofproto.c. I would
> really appreciate anyone familiar with this code giving me some
> feedback. I have copied the code snip below.
>
> My question is:
> 1) What is the main difference between rule_make_actions() and
> rule_execute()? In handle_odp_miss_msg(), we call both
> rule_make_actions() and rule_execute(), both calls xact_actions() that
> goes through list of actions to contruct odp actions. I can see
> rule_execute() not only calls xact_actions() to construct, but also
> execute odp actions. But I couldn't figure out the reason for doing
> construction twice. I must be missing some logic here. Could anyone
> please clarify for me? Same questions I inlined below as well.
>
> Thanks!
>
> static void
> handle_odp_miss_msg(struct ofproto *p, struct ofpbuf *packet)
> {
> =A0 =A0struct odp_msg *msg =3D packet->data;
> =A0 =A0struct rule *rule;
> =A0 =A0struct ofpbuf payload;
> =A0 =A0flow_t flow;
> ...
> ...
> =A0 =A0rule =3D lookup_valid_rule(p, &flow);
> =A0 =A0if (!rule) {
> =A0 =A0 =A0 =A0/* Don't send a packet-in if OFPPC_NO_PACKET_IN asserted. =
*/
> =A0 =A0 =A0 =A0struct ofport *port =3D port_array_get(&p->ports, msg->por=
t);
> =A0 =A0 =A0 =A0if (port) {
> =A0 =A0 =A0 =A0 =A0 =A0if (port->opp.config & OFPPC_NO_PACKET_IN) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0COVERAGE_INC(ofproto_no_packet_in);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* XXX install 'drop' flow entry */
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ofpbuf_delete(packet);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return;
> =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0} else {
> =A0 =A0 =A0 =A0 =A0 =A0VLOG_WARN_RL(&rl, "packet-in on unknown port %"PRI=
u16, msg->port);
> =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0COVERAGE_INC(ofproto_packet_in);
> =A0 =A0 =A0 =A0send_packet_in(p, packet);
> =A0 =A0 =A0 =A0return;
> =A0 =A0}
>
> =A0 =A0if (rule->cr.wc.wildcards) { <=3D=3D=3D so if it is a wildcard rul=
e we
> construct the odp actions
> =A0 =A0 =A0 =A0rule =3D rule_create_subrule(p, rule, &flow);
> =A0 =A0 =A0 =A0rule_make_actions(p, rule, packet);
> =A0 =A0} else {
> =A0 =A0 =A0 =A0if (!rule->may_install) {
> =A0 =A0 =A0 =A0 =A0 =A0/* The rule is not installable, that is, we need t=
o process every
> =A0 =A0 =A0 =A0 =A0 =A0 * packet, so process the current packet and set i=
ts actions into
> =A0 =A0 =A0 =A0 =A0 =A0 * 'subrule'. */
> =A0 =A0 =A0 =A0 =A0 =A0rule_make_actions(p, rule, packet);
> =A0 =A0 =A0 =A0} else {
> =A0 =A0 =A0 =A0 =A0 =A0/* XXX revalidate rule if it needs it */
> =A0 =A0 =A0 =A0}
> =A0 =A0}
>
> =A0 =A0if (rule->super && rule->super->cr.priority =3D=3D FAIL_OPEN_PRIOR=
ITY) {
> =A0 =A0 =A0 =A0/*
> =A0 =A0 =A0 =A0 * Extra-special case for fail-open mode.
> =A0 =A0 =A0 =A0 *
> =A0 =A0 =A0 =A0 * We are in fail-open mode and the packet matched the fai=
l-open rule,
> =A0 =A0 =A0 =A0 * but we are connected to a controller too. =A0We should =
send the packet
> =A0 =A0 =A0 =A0 * up to the controller in the hope that it will try to se=
t up a flow
> =A0 =A0 =A0 =A0 * and thereby allow us to exit fail-open.
> =A0 =A0 =A0 =A0 *
> =A0 =A0 =A0 =A0 * See the top-level comment in fail-open.c for more infor=
mation.
> =A0 =A0 =A0 =A0 */
> =A0 =A0 =A0 =A0send_packet_in(p, ofpbuf_clone_with_headroom(packet,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 DPIF_RECV_MSG_PADDING));
> =A0 =A0}
>
> =A0 =A0ofpbuf_pull(packet, sizeof *msg);
> =A0 =A0rule_execute(p, rule, packet, &flow); <=3D=3D in rule_execute
> =A0 =A0rule_reinstall(p, rule);
>
> static void
> rule_execute(struct ofproto *ofproto, struct rule *rule,
> =A0 =A0 =A0 =A0 =A0 =A0 struct ofpbuf *packet, const flow_t *flow)
> {
> =A0 =A0const union odp_action *actions;
> =A0 =A0struct odp_flow_stats stats;
> =A0 =A0size_t n_actions;
> =A0 =A0struct odp_actions a;
>
> =A0 =A0assert(ofpbuf_headroom(packet) >=3D sizeof(struct ofp_packet_in));
>
> =A0 =A0/* Grab or compose the ODP actions.
> =A0 =A0 *
> =A0 =A0 * The special case for an exact-match 'rule' where 'flow' is not =
the
> =A0 =A0 * rule's flow is important to avoid, e.g., sending a packet out i=
ts input
> =A0 =A0 * port simply because the ODP actions were composed for the wrong
> =A0 =A0 * scenario. */
> =A0 =A0if (rule->cr.wc.wildcards || !flow_equal(flow, &rule->cr.flow)) {
> <=3D=3D=3D if wildcard we call xlate_actions() again, why?
> =A0 =A0 =A0 =A0struct rule *super =3D rule->super ? rule->super : rule;
> =A0 =A0 =A0 =A0if (xlate_actions(super->actions, super->n_actions, flow, =
ofproto,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0packet, &a, NULL, 0, N=
ULL)) {
> =A0 =A0 =A0 =A0 =A0 =A0ofpbuf_delete(packet);
> =A0 =A0 =A0 =A0 =A0 =A0return;
> =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0actions =3D a.actions;
> =A0 =A0 =A0 =A0n_actions =3D a.n_actions;
> =A0 =A0} else {
> =A0 =A0 =A0 =A0actions =3D rule->odp_actions;
> =A0 =A0 =A0 =A0n_actions =3D rule->n_odp_actions;
> =A0 =A0}


More information about the discuss mailing list