From: Ben Pfaff Date: Mon, 16 Mar 2009 21:40:59 +0000 (-0700) Subject: dpctl: Add support for OFPAT_SET_DL_SRC and ..._DST actions. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4a1d661c2fe9fc7703d7c96878e2d4c44090104;p=openvswitch dpctl: Add support for OFPAT_SET_DL_SRC and ..._DST actions. Originally from a patch by Jean Tourrilhes, but the code here had moved on so much in the meantime that none of the original changes applied any longer. --- diff --git a/utilities/dpctl.8.in b/utilities/dpctl.8.in index 0ddbc7eb..d72fcf91 100644 --- a/utilities/dpctl.8.in +++ b/utilities/dpctl.8.in @@ -440,6 +440,12 @@ as necessary to match the value specified. Valid values are between 0 .IP \fBstrip_vlan\fR Strips the VLAN tag from a packet if it is present. + +.IP \fBmod_dl_src\fB:\fImac\fR +Sets the source Ethernet address to \fImac\fR. + +.IP \fBmod_dl_dst\fB:\fImac\fR +Sets the destination Ethernet address to \fImac\fR. .RE .IP diff --git a/utilities/dpctl.c b/utilities/dpctl.c index d8303a47..e3cbace1 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -825,6 +825,14 @@ put_output_action(struct ofpbuf *b, uint16_t port) return oao; } +static void +put_dl_addr_action(struct ofpbuf *b, uint16_t type, const char *addr) +{ + struct ofp_action_dl_addr *oada = put_action(b, sizeof *oada, type); + str_to_mac(addr, oada->dl_addr); +} + + static bool parse_port_name(const char *name, uint16_t *port) { @@ -886,6 +894,10 @@ str_to_action(char *str, struct ofpbuf *b) struct ofp_action_header *ah; ah = put_action(b, sizeof *ah, OFPAT_STRIP_VLAN); ah->type = htons(OFPAT_STRIP_VLAN); + } else if (!strcasecmp(act, "mod_dl_src")) { + 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, "output")) { put_output_action(b, str_to_u32(arg)); #ifdef SUPPORT_SNAT