From e423eca6e9bb71cb6e61fa3aeaa70e5525507770 Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Mon, 16 Nov 2009 17:58:26 -0800 Subject: [PATCH] ovs-ofctl: Add support for transport and network modification actions Add support to ovs-ofctl for modifying the network source and destination IP address with the "mod_nw_src" and "mod_nw_dst" actions, respectively. And support modifying the TCP/UDP source and destination ports with the "mod_tp_src" and "mod_tp_dst" actions, respectively. --- utilities/ovs-ofctl.8.in | 12 ++++++++++++ utilities/ovs-ofctl.c | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in index 2e2b38b3..439d3f5b 100644 --- a/utilities/ovs-ofctl.8.in +++ b/utilities/ovs-ofctl.8.in @@ -352,6 +352,18 @@ Sets the source Ethernet address to \fImac\fR. .IP \fBmod_dl_dst\fB:\fImac\fR Sets the destination Ethernet address to \fImac\fR. + +.IP \fBmod_nw_src\fB:\fIip\fR +Sets the IPv4 source address to \fIip\fR. + +.IP \fBmod_nw_dst\fB:\fIip\fR +Sets the IPv4 destination address to \fIip\fR. + +.IP \fBmod_tp_src\fB:\fIport\fR +Sets the TCP or UDP source port to \fIport\fR. + +.IP \fBmod_tp_dst\fB:\fIport\fR +Sets the TCP or UDP destination port to \fIport\fR. .RE .IP diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index ec8a0e1e..db6038a0 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -599,6 +599,22 @@ str_to_action(char *str, struct ofpbuf *b) put_dl_addr_action(b, OFPAT_SET_DL_SRC, arg); } else if (!strcasecmp(act, "mod_dl_dst")) { put_dl_addr_action(b, OFPAT_SET_DL_DST, arg); + } else if (!strcasecmp(act, "mod_nw_src")) { + struct ofp_action_nw_addr *na; + na = put_action(b, sizeof *na, OFPAT_SET_NW_SRC); + str_to_ip(arg, &na->nw_addr); + } else if (!strcasecmp(act, "mod_nw_dst")) { + struct ofp_action_nw_addr *na; + na = put_action(b, sizeof *na, OFPAT_SET_NW_DST); + str_to_ip(arg, &na->nw_addr); + } else if (!strcasecmp(act, "mod_tp_src")) { + struct ofp_action_tp_port *ta; + ta = put_action(b, sizeof *ta, OFPAT_SET_TP_SRC); + ta->tp_port = htons(str_to_u32(arg)); + } else if (!strcasecmp(act, "mod_tp_dst")) { + struct ofp_action_tp_port *ta; + ta = put_action(b, sizeof *ta, OFPAT_SET_TP_DST); + ta->tp_port = htons(str_to_u32(arg)); } else if (!strcasecmp(act, "output")) { put_output_action(b, str_to_u32(arg)); } else if (!strcasecmp(act, "drop")) { -- 2.30.2