Hi All I have been trying to add a flow entry to the switch when I receive a datapath_join_event using switch.cc component. My set of actions include (set_nw_tos,set_tp_port and output). When a packet arrives, I modify the ToS bit, Src/Dst port using set of actions and want to send the packet back to the same host using OFPP_IN_PORT. However, I am not receiving the packet back in my input port (source host). When I replace the OFPP_IN_PORT with OFPP_FLOOD and check in the destination host, I can see that the ToS, Src and Dst Port getting modified.
I use the following code to install the flow: struct ofp_flow_mod *ofm = (struct ofp_flow_mod *)malloc(sizeof(structofp_flow_mod)+( 4*sizeof(struct ofp_action_header)); ofm->header.version = OFP_VERSION; ofm->header.type = OFPT_FLOW_MOD; ofm->header.length = htons(sizeof(struct ofp_flow_mod)+ action_length* sizeof(struct ofp_action_header)); ofm->match.wildcards = htonl(1<<20 | 1<<1); ofm->match.in_port = htons(1); ofm->match.dl_src[0] = 0x08; ofm->match.dl_src[1] = 0x00; ofm->match.dl_src[2] = 0x27; ofm->match.dl_src[3] = 0x7c; ofm->match.dl_src[4] = 0xe5; ofm->match.dl_src[5] = 0xb8; ofm->match.dl_dst[0] = 0x08; ofm->match.dl_dst[1] = 0x00; ofm->match.dl_dst[2] = 0x27; ofm->match.dl_dst[3] = 0x86; ofm->match.dl_dst[4] = 0xfb; ofm->match.dl_dst[5] = 0x92; ofm->match.dl_type = htons(0x800); ofm->match.nw_proto = 6; ofm->match.pad1[0] = (uint8_t)0; ofm->match.nw_tos = 0x10; ofm->match.nw_src = (inet_addr(SRC_IP)); ofm->match.nw_dst = (inet_addr(DST_IP)); ofm->match.tp_src = htons(SRC_PORT); ofm->match.tp_dst = htons(DST_PORT); ofm->match.pad2[0] = 0; ofm->match.pad2[1] = 0; ofm->cookie = htonl(0); ofm->command = htons(OFPFC_ADD); ofm->buffer_id = htonl(UINT32_MAX); ofm->idle_timeout = htons(OFP_FLOW_PERMANENT); ofm->hard_timeout = htons(OFP_FLOW_PERMANENT); ofm->priority = htons(OFP_DEFAULT_PRIORITY); ofm->flags = htons(ofd_flow_mod_flags()); ofm->out_port = htons(OFPP_NONE); /* Handling Set of Actions */ // SET NW TOS ofp_action_nw_tos *nw_tos = (ofp_action_nw_tos *)malloc(sizeof (ofp_action_nw_tos)); nw_tos->type = htons(OFPAT_SET_NW_TOS); nw_tos->len = htons(sizeof(ofp_action_nw_tos)); nw_tos->nw_tos = 0x11; // SET NW TP SRC ofp_action_tp_port *tp_src = (ofp_action_tp_port *)malloc(sizeof (ofp_action_tp_port)); tp_src->type = htons(OFPAT_SET_TP_SRC); tp_src->len = htons(sizeof(ofp_action_tp_port)); tp_src->tp_port = htons(1234); // SET NW TP DST ofp_action_tp_port *tp_dst = (ofp_action_tp_port *)malloc(sizeof (ofp_action_tp_port)); tp_dst->type = htons(OFPAT_SET_TP_DST); tp_dst->len = htons(sizeof(ofp_action_tp_port)); tp_dst->tp_port = htons(4100); // OUTPUT ACTION ofp_action_output *action = (ofp_action_output *)malloc(sizeof (ofp_action_output)); action->type = htons(OFPAT_OUTPUT); action->len = htons(sizeof(ofp_action_output)); action->port = htons(OFPP_IN_PORT); //*WHEN I REPLACE WITH OFPP_FLOOD, i receive the packet in the destination host with the above actions getting modified. However, I want to set the above actions and send it back to the source host.* action->max_len = htons(0); memcpy(action_type, (unsigned char *)nw_tos, sizeof(ofp_action_nw_tos)); memcpy(action_type + sizeof(ofp_action_nw_tos), (unsigned char *)tp_src, sizeof(ofp_action_tp_port)); memcpy(action_type + sizeof(ofp_action_nw_tos) + sizeof(ofp_action_tp_port), (unsigned char *)tp_dst, sizeof(ofp_action_tp_port)); memcpy(action_type + sizeof(ofp_action_nw_tos) + sizeof(ofp_action_tp_port)+ sizeof(ofp_action_tp_port), (unsigned char *)action, sizeof (ofp_action_output)); memcpy(ofm->actions, action_type, no_of_actions_len); send_openflow_command(dje.datapath_id, &ofm->header, true); I checked in wireshark to verify the flow mod and it seems to work correctly. I am running my host machines in VirtualBox VMs and the switch (OpenFlow 1.0) is running in my host system. Is there something that I am missing? Thanks Sriram
_______________________________________________ nox-dev mailing list [email protected] http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org
