Skip to content

Commit

Permalink
openflow: Split OFPAT_* into OFPAT10_* and OFPAT11_*.
Browse files Browse the repository at this point in the history
An upcoming commit will start referring to OpenFlow 1.1 actions, which are
renumbered relative to OpenFlow 1.0 actions, so this commit prepares by
changing all the existing uses of OFPAT_* to instead use OFPAT10_*.

This commit also introduces the OFPAT11_* constants.

Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
blp committed Mar 7, 2012
1 parent 6c03861 commit 08f94c0
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 157 deletions.
70 changes: 35 additions & 35 deletions include/openflow/openflow-1.0.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,28 +268,28 @@ struct ofp_packet_in {
};
OFP_ASSERT(sizeof(struct ofp_packet_in) == 20);

enum ofp_action_type {
OFPAT_OUTPUT, /* Output to switch port. */
OFPAT_SET_VLAN_VID, /* Set the 802.1q VLAN id. */
OFPAT_SET_VLAN_PCP, /* Set the 802.1q priority. */
OFPAT_STRIP_VLAN, /* Strip the 802.1q header. */
OFPAT_SET_DL_SRC, /* Ethernet source address. */
OFPAT_SET_DL_DST, /* Ethernet destination address. */
OFPAT_SET_NW_SRC, /* IP source address. */
OFPAT_SET_NW_DST, /* IP destination address. */
OFPAT_SET_NW_TOS, /* IP ToS (DSCP field, 6 bits). */
OFPAT_SET_TP_SRC, /* TCP/UDP source port. */
OFPAT_SET_TP_DST, /* TCP/UDP destination port. */
OFPAT_ENQUEUE, /* Output to queue. */
OFPAT_VENDOR = 0xffff
};

/* Action structure for OFPAT_OUTPUT, which sends packets out 'port'.
enum ofp10_action_type {
OFPAT10_OUTPUT, /* Output to switch port. */
OFPAT10_SET_VLAN_VID, /* Set the 802.1q VLAN id. */
OFPAT10_SET_VLAN_PCP, /* Set the 802.1q priority. */
OFPAT10_STRIP_VLAN, /* Strip the 802.1q header. */
OFPAT10_SET_DL_SRC, /* Ethernet source address. */
OFPAT10_SET_DL_DST, /* Ethernet destination address. */
OFPAT10_SET_NW_SRC, /* IP source address. */
OFPAT10_SET_NW_DST, /* IP destination address. */
OFPAT10_SET_NW_TOS, /* IP ToS (DSCP field, 6 bits). */
OFPAT10_SET_TP_SRC, /* TCP/UDP source port. */
OFPAT10_SET_TP_DST, /* TCP/UDP destination port. */
OFPAT10_ENQUEUE, /* Output to queue. */
OFPAT10_VENDOR = 0xffff
};

/* Action structure for OFPAT10_OUTPUT, which sends packets out 'port'.
* When the 'port' is the OFPP_CONTROLLER, 'max_len' indicates the max
* number of bytes to send. A 'max_len' of zero means no bytes of the
* packet should be sent. */
struct ofp_action_output {
ovs_be16 type; /* OFPAT_OUTPUT. */
ovs_be16 type; /* OFPAT10_OUTPUT. */
ovs_be16 len; /* Length is 8. */
ovs_be16 port; /* Output port. */
ovs_be16 max_len; /* Max length to send to controller. */
Expand All @@ -301,62 +301,62 @@ OFP_ASSERT(sizeof(struct ofp_action_output) == 8);
* set. */
#define OFP_VLAN_NONE 0xffff

/* Action structure for OFPAT_SET_VLAN_VID. */
/* Action structure for OFPAT10_SET_VLAN_VID. */
struct ofp_action_vlan_vid {
ovs_be16 type; /* OFPAT_SET_VLAN_VID. */
ovs_be16 type; /* OFPAT10_SET_VLAN_VID. */
ovs_be16 len; /* Length is 8. */
ovs_be16 vlan_vid; /* VLAN id. */
uint8_t pad[2];
};
OFP_ASSERT(sizeof(struct ofp_action_vlan_vid) == 8);

/* Action structure for OFPAT_SET_VLAN_PCP. */
/* Action structure for OFPAT10_SET_VLAN_PCP. */
struct ofp_action_vlan_pcp {
ovs_be16 type; /* OFPAT_SET_VLAN_PCP. */
ovs_be16 type; /* OFPAT10_SET_VLAN_PCP. */
ovs_be16 len; /* Length is 8. */
uint8_t vlan_pcp; /* VLAN priority. */
uint8_t pad[3];
};
OFP_ASSERT(sizeof(struct ofp_action_vlan_pcp) == 8);

/* Action structure for OFPAT_SET_DL_SRC/DST. */
/* Action structure for OFPAT10_SET_DL_SRC/DST. */
struct ofp_action_dl_addr {
ovs_be16 type; /* OFPAT_SET_DL_SRC/DST. */
ovs_be16 type; /* OFPAT10_SET_DL_SRC/DST. */
ovs_be16 len; /* Length is 16. */
uint8_t dl_addr[OFP_ETH_ALEN]; /* Ethernet address. */
uint8_t pad[6];
};
OFP_ASSERT(sizeof(struct ofp_action_dl_addr) == 16);

/* Action structure for OFPAT_SET_NW_SRC/DST. */
/* Action structure for OFPAT10_SET_NW_SRC/DST. */
struct ofp_action_nw_addr {
ovs_be16 type; /* OFPAT_SET_TW_SRC/DST. */
ovs_be16 type; /* OFPAT10_SET_TW_SRC/DST. */
ovs_be16 len; /* Length is 8. */
ovs_be32 nw_addr; /* IP address. */
};
OFP_ASSERT(sizeof(struct ofp_action_nw_addr) == 8);

/* Action structure for OFPAT_SET_NW_TOS. */
/* Action structure for OFPAT10_SET_NW_TOS. */
struct ofp_action_nw_tos {
ovs_be16 type; /* OFPAT_SET_TW_TOS. */
ovs_be16 type; /* OFPAT10_SET_TW_TOS. */
ovs_be16 len; /* Length is 8. */
uint8_t nw_tos; /* IP TOS (DSCP field, 6 bits). */
uint8_t pad[3];
};
OFP_ASSERT(sizeof(struct ofp_action_nw_tos) == 8);

/* Action structure for OFPAT_SET_TP_SRC/DST. */
/* Action structure for OFPAT10_SET_TP_SRC/DST. */
struct ofp_action_tp_port {
ovs_be16 type; /* OFPAT_SET_TP_SRC/DST. */
ovs_be16 type; /* OFPAT10_SET_TP_SRC/DST. */
ovs_be16 len; /* Length is 8. */
ovs_be16 tp_port; /* TCP/UDP port. */
uint8_t pad[2];
};
OFP_ASSERT(sizeof(struct ofp_action_tp_port) == 8);

/* Action header for OFPAT_VENDOR. The rest of the body is vendor-defined. */
/* Action header for OFPAT10_VENDOR. The rest of the body is vendor-defined. */
struct ofp_action_vendor_header {
ovs_be16 type; /* OFPAT_VENDOR. */
ovs_be16 type; /* OFPAT10_VENDOR. */
ovs_be16 len; /* Length is a multiple of 8. */
ovs_be32 vendor; /* Vendor ID, which takes the same form
as in "struct ofp_vendor_header". */
Expand All @@ -367,7 +367,7 @@ OFP_ASSERT(sizeof(struct ofp_action_vendor_header) == 8);
* header and any padding used to make the action 64-bit aligned.
* NB: The length of an action *must* always be a multiple of eight. */
struct ofp_action_header {
ovs_be16 type; /* One of OFPAT_*. */
ovs_be16 type; /* One of OFPAT10_*. */
ovs_be16 len; /* Length of action, including this
header. This is the length of action,
including any padding to make it
Expand All @@ -376,9 +376,9 @@ struct ofp_action_header {
};
OFP_ASSERT(sizeof(struct ofp_action_header) == 8);

/* OFPAT_ENQUEUE action struct: send packets to given queue on port. */
/* OFPAT10_ENQUEUE action struct: send packets to given queue on port. */
struct ofp_action_enqueue {
ovs_be16 type; /* OFPAT_ENQUEUE. */
ovs_be16 type; /* OFPAT10_ENQUEUE. */
ovs_be16 len; /* Len is 16. */
ovs_be16 port; /* Port that queue belongs. Should
refer to a valid physical port
Expand Down
32 changes: 32 additions & 0 deletions include/openflow/openflow-1.1.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,36 @@ enum ofp11_type {
OFPT11_QUEUE_GET_CONFIG_REPLY, /* Controller/switch message */
};

enum ofp11_action_type {
OFPAT11_OUTPUT, /* Output to switch port. */
OFPAT11_SET_VLAN_VID, /* Set the 802.1q VLAN id. */
OFPAT11_SET_VLAN_PCP, /* Set the 802.1q priority. */
OFPAT11_SET_DL_SRC, /* Ethernet source address. */
OFPAT11_SET_DL_DST, /* Ethernet destination address. */
OFPAT11_SET_NW_SRC, /* IP source address. */
OFPAT11_SET_NW_DST, /* IP destination address. */
OFPAT11_SET_NW_TOS, /* IP ToS (DSCP field, 6 bits). */
OFPAT11_SET_NW_ECN, /* IP ECN (2 bits). */
OFPAT11_SET_TP_SRC, /* TCP/UDP/SCTP source port. */
OFPAT11_SET_TP_DST, /* TCP/UDP/SCTP destination port. */
OFPAT11_COPY_TTL_OUT, /* Copy TTL "outwards" -- from next-to-outermost
to outermost */
OFPAT11_COPY_TTL_IN, /* Copy TTL "inwards" -- from outermost to
next-to-outermost */
OFPAT11_SET_MPLS_LABEL, /* MPLS label */
OFPAT11_SET_MPLS_TC, /* MPLS TC */
OFPAT11_SET_MPLS_TTL, /* MPLS TTL */
OFPAT11_DEC_MPLS_TTL, /* Decrement MPLS TTL */

OFPAT11_PUSH_VLAN, /* Push a new VLAN tag */
OFPAT11_POP_VLAN, /* Pop the outer VLAN tag */
OFPAT11_PUSH_MPLS, /* Push a new MPLS tag */
OFPAT11_POP_MPLS, /* Pop the outer MPLS tag */
OFPAT11_SET_QUEUE, /* Set queue id when outputting to a port */
OFPAT11_GROUP, /* Apply group. */
OFPAT11_SET_NW_TTL, /* IP TTL. */
OFPAT11_DEC_NW_TTL, /* Decrement IP TTL. */
OFPAT11_EXPERIMENTER = 0xffff
};

#endif /* openflow/openflow-1.1.h */
2 changes: 1 addition & 1 deletion lib/learn.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ learn_execute(const struct nx_action_learn *learn, const struct flow *flow,
break;

case NX_LEARN_DST_OUTPUT:
ofputil_put_OFPAT_OUTPUT(&actions)->port = htons(value);
ofputil_put_OFPAT10_OUTPUT(&actions)->port = htons(value);
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/learning-switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ process_packet_in(struct lswitch *sw, struct rconn *rconn,
struct ofp_action_output oao;

memset(&oao, 0, sizeof oao);
oao.type = htons(OFPAT_OUTPUT);
oao.type = htons(OFPAT10_OUTPUT);
oao.len = htons(sizeof oao);
oao.port = htons(out_port);

Expand All @@ -481,7 +481,7 @@ process_packet_in(struct lswitch *sw, struct rconn *rconn,
struct ofp_action_enqueue oae;

memset(&oae, 0, sizeof oae);
oae.type = htons(OFPAT_ENQUEUE);
oae.type = htons(OFPAT10_ENQUEUE);
oae.len = htons(sizeof oae);
oae.port = htons(out_port);
oae.queue_id = htonl(queue_id);
Expand Down
36 changes: 18 additions & 18 deletions lib/ofp-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ put_output_action(struct ofpbuf *b, uint16_t port)
{
struct ofp_action_output *oao;

oao = ofputil_put_OFPAT_OUTPUT(b);
oao = ofputil_put_OFPAT10_OUTPUT(b);
oao->port = htons(port);
return oao;
}
Expand All @@ -141,7 +141,7 @@ parse_enqueue(struct ofpbuf *b, char *arg)
ovs_fatal(0, "\"enqueue\" syntax is \"enqueue:PORT:QUEUE\"");
}

oae = ofputil_put_OFPAT_ENQUEUE(b);
oae = ofputil_put_OFPAT10_ENQUEUE(b);
oae->port = htons(str_to_u32(port));
oae->queue_id = htonl(str_to_u32(queue));
}
Expand Down Expand Up @@ -320,47 +320,47 @@ parse_named_action(enum ofputil_action_code code, const struct flow *flow,
struct ofp_action_tp_port *oata;

switch (code) {
case OFPUTIL_OFPAT_OUTPUT:
case OFPUTIL_OFPAT10_OUTPUT:
parse_output(b, arg);
break;

case OFPUTIL_OFPAT_SET_VLAN_VID:
oavv = ofputil_put_OFPAT_SET_VLAN_VID(b);
case OFPUTIL_OFPAT10_SET_VLAN_VID:
oavv = ofputil_put_OFPAT10_SET_VLAN_VID(b);
oavv->vlan_vid = htons(str_to_u32(arg));
break;

case OFPUTIL_OFPAT_SET_VLAN_PCP:
oavp = ofputil_put_OFPAT_SET_VLAN_PCP(b);
case OFPUTIL_OFPAT10_SET_VLAN_PCP:
oavp = ofputil_put_OFPAT10_SET_VLAN_PCP(b);
oavp->vlan_pcp = str_to_u32(arg);
break;

case OFPUTIL_OFPAT_STRIP_VLAN:
ofputil_put_OFPAT_STRIP_VLAN(b);
case OFPUTIL_OFPAT10_STRIP_VLAN:
ofputil_put_OFPAT10_STRIP_VLAN(b);
break;

case OFPUTIL_OFPAT_SET_DL_SRC:
case OFPUTIL_OFPAT_SET_DL_DST:
case OFPUTIL_OFPAT10_SET_DL_SRC:
case OFPUTIL_OFPAT10_SET_DL_DST:
oada = ofputil_put_action(code, b);
str_to_mac(arg, oada->dl_addr);
break;

case OFPUTIL_OFPAT_SET_NW_SRC:
case OFPUTIL_OFPAT_SET_NW_DST:
case OFPUTIL_OFPAT10_SET_NW_SRC:
case OFPUTIL_OFPAT10_SET_NW_DST:
oana = ofputil_put_action(code, b);
str_to_ip(arg, &oana->nw_addr);
break;

case OFPUTIL_OFPAT_SET_NW_TOS:
ofputil_put_OFPAT_SET_NW_TOS(b)->nw_tos = str_to_u32(arg);
case OFPUTIL_OFPAT10_SET_NW_TOS:
ofputil_put_OFPAT10_SET_NW_TOS(b)->nw_tos = str_to_u32(arg);
break;

case OFPUTIL_OFPAT_SET_TP_SRC:
case OFPUTIL_OFPAT_SET_TP_DST:
case OFPUTIL_OFPAT10_SET_TP_SRC:
case OFPUTIL_OFPAT10_SET_TP_DST:
oata = ofputil_put_action(code, b);
oata->tp_port = htons(str_to_u32(arg));
break;

case OFPUTIL_OFPAT_ENQUEUE:
case OFPUTIL_OFPAT10_ENQUEUE:
parse_enqueue(b, arg);
break;

Expand Down
24 changes: 12 additions & 12 deletions lib/ofp-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ ofp_print_action(struct ds *s, const union ofp_action *a,
uint16_t port;

switch (code) {
case OFPUTIL_OFPAT_OUTPUT:
case OFPUTIL_OFPAT10_OUTPUT:
port = ntohs(a->output.port);
if (port < OFPP_MAX) {
ds_put_format(s, "output:%"PRIu16, port);
Expand All @@ -198,55 +198,55 @@ ofp_print_action(struct ds *s, const union ofp_action *a,
}
break;

case OFPUTIL_OFPAT_ENQUEUE:
case OFPUTIL_OFPAT10_ENQUEUE:
oae = (const struct ofp_action_enqueue *) a;
ds_put_format(s, "enqueue:");
ofputil_format_port(ntohs(oae->port), s);
ds_put_format(s, "q%"PRIu32, ntohl(oae->queue_id));
break;

case OFPUTIL_OFPAT_SET_VLAN_VID:
case OFPUTIL_OFPAT10_SET_VLAN_VID:
ds_put_format(s, "mod_vlan_vid:%"PRIu16,
ntohs(a->vlan_vid.vlan_vid));
break;

case OFPUTIL_OFPAT_SET_VLAN_PCP:
case OFPUTIL_OFPAT10_SET_VLAN_PCP:
ds_put_format(s, "mod_vlan_pcp:%"PRIu8, a->vlan_pcp.vlan_pcp);
break;

case OFPUTIL_OFPAT_STRIP_VLAN:
case OFPUTIL_OFPAT10_STRIP_VLAN:
ds_put_cstr(s, "strip_vlan");
break;

case OFPUTIL_OFPAT_SET_DL_SRC:
case OFPUTIL_OFPAT10_SET_DL_SRC:
oada = (const struct ofp_action_dl_addr *) a;
ds_put_format(s, "mod_dl_src:"ETH_ADDR_FMT,
ETH_ADDR_ARGS(oada->dl_addr));
break;

case OFPUTIL_OFPAT_SET_DL_DST:
case OFPUTIL_OFPAT10_SET_DL_DST:
oada = (const struct ofp_action_dl_addr *) a;
ds_put_format(s, "mod_dl_dst:"ETH_ADDR_FMT,
ETH_ADDR_ARGS(oada->dl_addr));
break;

case OFPUTIL_OFPAT_SET_NW_SRC:
case OFPUTIL_OFPAT10_SET_NW_SRC:
ds_put_format(s, "mod_nw_src:"IP_FMT, IP_ARGS(&a->nw_addr.nw_addr));
break;

case OFPUTIL_OFPAT_SET_NW_DST:
case OFPUTIL_OFPAT10_SET_NW_DST:
ds_put_format(s, "mod_nw_dst:"IP_FMT, IP_ARGS(&a->nw_addr.nw_addr));
break;

case OFPUTIL_OFPAT_SET_NW_TOS:
case OFPUTIL_OFPAT10_SET_NW_TOS:
ds_put_format(s, "mod_nw_tos:%d", a->nw_tos.nw_tos);
break;

case OFPUTIL_OFPAT_SET_TP_SRC:
case OFPUTIL_OFPAT10_SET_TP_SRC:
ds_put_format(s, "mod_tp_src:%d", ntohs(a->tp_port.tp_port));
break;

case OFPUTIL_OFPAT_SET_TP_DST:
case OFPUTIL_OFPAT10_SET_TP_DST:
ds_put_format(s, "mod_tp_dst:%d", ntohs(a->tp_port.tp_port));
break;

Expand Down
Loading

0 comments on commit 08f94c0

Please sign in to comment.