Hello,

I am looking at decode_openflow10_action function at lib/ofp-actions.c. I
am trying to understand how the code is performed. I have been testing it,
but still no clue.

I provide, at the end, my "test code".

My problem is that I have created a custom action with type = 0x000d, and I
am trying to know why this action goes to the default part of the switch
statement, and other actions "go nowhere". I can explain. From the
controller, I create 3 rules (same rules for different ports) which
contains SET_SRC_MAC (type 0x0004) and my custom action (0x000d). At the
end, I provide the output of the test.

I would also like to know, when does the #define OFPAT10_ACTION(ENUM,
STRUCT, NAME)  part occurs. It is after the return statement >.<"

Thank you, and sorry if this question is too simple, but I don't get how it
works.

Thanks again,
Raúl

--------------------- CODE ------------------------------------
// The real implementation does not have any file writing variable/function

static enum ofperr
decode_openflow10_action(const union ofp_action *a,
                         enum ofputil_action_code *code)
{

FILE *f;
 f = fopen("/home/raul/file.txt", "ab+");
fprintf(f, ">ALL< 0x%x 0x%x (%d %d)   (0x%x %d) (0x%x %d)\n", a->type,
a->header.len, a->type, a->header.len, OFPAT10_VENDOR,
OFPAT10_VENDOR,CONSTANT_HTONS(OFPAT10_VENDOR),CONSTANT_HTONS(OFPAT10_VENDOR));
fclose(f);
    switch (a->type) {
    case CONSTANT_HTONS(OFPAT10_VENDOR):
    f = fopen("/home/raul/file.txt", "ab+");
fprintf(f, "  >V< 0x%x 0x%x (%d %d)   (0x%x %d) (0x%x %d)\n", a->type,
a->header.len, a->type, a->header.len, OFPAT10_VENDOR,
OFPAT10_VENDOR,CONSTANT_HTONS(OFPAT10_VENDOR),CONSTANT_HTONS(OFPAT10_VENDOR));
fclose(f);
        return decode_nxast_action(a, code);

#define OFPAT10_ACTION(ENUM, STRUCT, NAME)                          \
        case CONSTANT_HTONS(ENUM):                                  \
            if (a->header.len == htons(sizeof(struct STRUCT))) {    \
                *code = OFPUTIL_##ENUM;                             \
                return 0;                                           \
            } else {                                                \
                return OFPERR_OFPBAC_BAD_LEN;                       \
            }                                                       \
            break;
#include "ofp-util.def"
        f = fopen("/home/raul/file.txt", "ab+");
fprintf(f, "  >WTF< 0x%x 0x%x (%d %d)   (0x%x %d) (0x%x %d)\n", a->type,
a->header.len, a->type, a->header.len, OFPAT10_VENDOR,
OFPAT10_VENDOR,CONSTANT_HTONS(OFPAT10_VENDOR),CONSTANT_HTONS(OFPAT10_VENDOR));
fclose(f);

    /*case (0x0d00):  something with htons? RAUL SUAREZ MARIN
    *code = OFPUTIL_OFPAT10_SET_ESMC_SSM;
    return 0;*/

    default:
    f = fopen("/home/raul/file.txt", "ab+");
fprintf(f, ">F< 0x%x 0x%x (%d %d)   (0x%x %d) (0x%x %d)\n", a->type,
a->header.len, a->type, a->header.len, OFPAT10_VENDOR,
OFPAT10_VENDOR,CONSTANT_HTONS(OFPAT10_VENDOR),CONSTANT_HTONS(OFPAT10_VENDOR));
fclose(f);
        return OFPERR_OFPBAC_BAD_TYPE;
    }
}

---------------- OUTPUT OF THE TEST
----------------------------------------------
V = Verified => works fine
F = Failed
ALL = Everything

fprintf(f, ">F< 0x%x 0x%x (%d %d)   (0x%x %d) (0x%x %d)\n", a->type,
a->header.len, a->type, a->header.len, OFPAT10_VENDOR,
OFPAT10_VENDOR,CONSTANT_HTONS(OFPAT10_VENDOR),CONSTANT_HTONS(OFPAT10_VENDOR));

>ALL< 0x0 0x800 (0 2048)   (0xffff 65535) (0xffff 65535)
>ALL< 0x0 0x800 (0 2048)   (0xffff 65535) (0xffff 65535)
>ALL< 0x0 0x800 (0 2048)   (0xffff 65535) (0xffff 65535)
>ALL< 0x0 0x800 (0 2048)   (0xffff 65535) (0xffff 65535)
>ALL< 0x0 0x800 (0 2048)   (0xffff 65535) (0xffff 65535)
>ALL< 0x0 0x800 (0 2048)   (0xffff 65535) (0xffff 65535)
>ALL< 0x400 0x1000 (1024 4096)   (0xffff 65535) (0xffff 65535)
>ALL< 0xd00 0x800 (3328 2048)   (0xffff 65535) (0xffff 65535)
>F< 0xd00 0x800 (3328 2048)   (0xffff 65535) (0xffff 65535) <------------
clearly, 0x000d failed
>ALL< 0x400 0x1000 (1024 4096)   (0xffff 65535) (0xffff 65535) <------ what
happened to this, this dissapeared? Did not go neither to >V< nor >F<
>ALL< 0xd00 0x800 (3328 2048)   (0xffff 65535) (0xffff 65535)
>F< 0xd00 0x800 (3328 2048)   (0xffff 65535) (0xffff 65535)
>ALL< 0x400 0x1000 (1024 4096)   (0xffff 65535) (0xffff 65535)
>ALL< 0xd00 0x800 (3328 2048)   (0xffff 65535) (0xffff 65535)
>F< 0xd00 0x800 (3328 2048)   (0xffff 65535) (0xffff 65535)
>ALL< 0x400 0x1000 (1024 4096)   (0xffff 65535) (0xffff 65535)
>ALL< 0xd00 0x800 (3328 2048)   (0xffff 65535) (0xffff 65535)
>F< 0xd00 0x800 (3328 2048)   (0xffff 65535) (0xffff 65535)
>ALL< 0x400 0x1000 (1024 4096)   (0xffff 65535) (0xffff 65535)
>ALL< 0xd00 0x800 (3328 2048)   (0xffff 65535) (0xffff 65535)
>F< 0xd00 0x800 (3328 2048)   (0xffff 65535) (0xffff 65535)
>ALL< 0x400 0x1000 (1024 4096)   (0xffff 65535) (0xffff 65535)
>ALL< 0xd00 0x800 (3328 2048)   (0xffff 65535) (0xffff 65535)
>F< 0xd00 0x800 (3328 2048)   (0xffff 65535) (0xffff 65535)
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to