prev_port = -1;
}
- if (likely(a->type == ntohs(OFPAT_OUTPUT))) {
+ if (likely(a->type == htons(OFPAT_OUTPUT))) {
prev_port = ntohs(a->arg.output.port);
max_len = ntohs(a->arg.output.max_len);
} else {
new = a->arg.nw_addr;
- if (a->type == OFPAT_SET_NW_SRC)
+ if (a->type == htons(OFPAT_SET_NW_SRC))
field = &nh->saddr;
else
field = &nh->daddr;
if (nw_proto == IPPROTO_TCP) {
struct tcphdr *th = tcp_hdr(skb);
- if (a->type == OFPAT_SET_TP_SRC)
+ if (a->type == htons(OFPAT_SET_TP_SRC))
field = &th->source;
else
field = &th->dest;
} else if (nw_proto == IPPROTO_UDP) {
struct udphdr *th = udp_hdr(skb);
- if (a->type == OFPAT_SET_TP_SRC)
+ if (a->type == htons(OFPAT_SET_TP_SRC))
field = &th->source;
else
field = &th->dest;
/* Verify we were given a vlan packet */
- if (vh->h_vlan_proto != __constant_htons(ETH_P_8021Q))
+ if (vh->h_vlan_proto != htons(ETH_P_8021Q))
return skb;
memmove(skb->data + VLAN_HLEN, skb->data, 2 * VLAN_ETH_ALEN);
uint16_t new_id = a->arg.vlan_id;
if (new_id != OFP_VLAN_NONE) {
- if (key->dl_vlan != __constant_htons(OFP_VLAN_NONE)) {
+ if (key->dl_vlan != htons(OFP_VLAN_NONE)) {
/* Modify vlan id, but maintain other TCI values */
struct vlan_ethhdr *vh = vlan_eth_hdr(skb);
vh->h_vlan_TCI = (vh->h_vlan_TCI
- & ~(__constant_htons(VLAN_VID_MASK))) | htons(new_id);
+ & ~(htons(VLAN_VID_MASK))) | htons(new_id);
} else {
/* Add vlan header */
skb = vlan_put_tag(skb, new_id);
struct sk_buff *execute_setter(struct sk_buff *skb, uint16_t eth_proto,
const struct sw_flow_key *key, const struct ofp_action *a)
{
- switch (a->type) {
+ switch (ntohs(a->type)) {
case OFPAT_SET_DL_VLAN:
skb = modify_vlan(skb, key, a);
break;
break;
default:
- BUG();
+ if (net_ratelimit())
+ printk("execute_setter: unknown action: %d\n", ntohs(a->type));
}
return skb;
set_action_data(struct sk_buff *skb, struct sw_flow_key *key, struct ofp_action *a)
{
if (key != NULL) {
- switch(a->type) {
+ switch(ntohs(a->type)) {
case(OFPAT_SET_DL_SRC):
memcpy(a->arg.dl_addr, key->dl_src, sizeof key->dl_src);
break;
}
if (a != NULL) {
- switch(a->type) {
+ switch(ntohs(a->type)) {
case(OFPAT_SET_DL_SRC):
if (memcmp(a->arg.dl_addr, eh->h_source, sizeof eh->h_source) != 0) {
unit_fail("Source eth addr has not been set");
test_l3_l4(void)
{
struct ofp_action action;
+ uint16_t a_type;
struct sk_buff *skb;
struct sw_flow_key key;
unsigned int i, j;
if (unit_failed())
return;
- for (action.type = OFPAT_SET_DL_SRC;
- action.type <= OFPAT_SET_TP_DST;
- action.type++)
+ for (a_type = OFPAT_SET_DL_SRC;
+ a_type <= OFPAT_SET_TP_DST;
+ a_type++)
{
+ action.type = htons(a_type);
set_action_data(skb, NULL, &action);
for(j = 0; j < 2; j++) {
skb = execute_setter(skb, eth_proto, &key, &action);
if (ret != 0)
break;
}
+
+ if (ret == 0)
+ printk("\nL3/L4 actions test passed.\n");
}
int
eh = eth_hdr(skb);
orig_id = eh->h_proto;
- action.type = OFPAT_SET_DL_VLAN;
+ action.type = htons(OFPAT_SET_DL_VLAN);
// Add a random vlan tag
new_id = (uint16_t) random32() & VLAN_VID_MASK;
printk("\nVLAN actions test passed.\n");
return ret;
-
-
}
/*