diff options
author | Rob Gulewich <robert.gulewich@joyent.com> | 2012-08-21 22:07:55 +0000 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2013-08-08 09:20:06 -0700 |
commit | 2954adb080121c02025bb94537c313e6f51c9fd7 (patch) | |
tree | cad1750cda4ea6310b58549a370e42ae1f6151ac | |
parent | da4badc008f69df74f592b0831d92baa6dfcee76 (diff) | |
download | illumos-joyent-2954adb080121c02025bb94537c313e6f51c9fd7.tar.gz |
3931 vrrpadm should work with a vnic as its link
3932 vrrpadm dies when its configuration file doesn't exist
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Dan McDonald <danmcd@nexenta.com>
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.lib/vrrpd/vrrpd.c | 23 | ||||
-rw-r--r-- | usr/src/lib/libvrrpadm/common/libvrrpadm.c | 23 |
2 files changed, 38 insertions, 8 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.lib/vrrpd/vrrpd.c b/usr/src/cmd/cmd-inet/usr.lib/vrrpd/vrrpd.c index a319c119a6..096ef2422b 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/vrrpd/vrrpd.c +++ b/usr/src/cmd/cmd-inet/usr.lib/vrrpd/vrrpd.c @@ -23,6 +23,10 @@ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ +/* + * Copyright (c) 2012, Joyent, Inc. All rights reserved. + */ + #include <sys/types.h> #include <sys/socket.h> #include <sys/sockio.h> @@ -2003,9 +2007,19 @@ vrrpd_updateconf(vrrp_vr_conf_t *newconf, uint_t op) op == VRRP_CONF_UPDATE ? "update" : "delete"); if ((fp = fopen(vrrpd_conffile, "r+F")) == NULL) { - vrrp_log(VRRP_ERR, "vrrpd_updateconf(): open %s failed: %s", - vrrpd_conffile, strerror(errno)); - return (VRRP_EDB); + if (errno != ENOENT) { + vrrp_log(VRRP_ERR, "vrrpd_updateconf(): open %s for " + "update failed: %s", vrrpd_conffile, + strerror(errno)); + return (VRRP_EDB); + } + + if ((fp = fopen(vrrpd_conffile, "w+F")) == NULL) { + vrrp_log(VRRP_ERR, "vrrpd_updateconf(): open %s for " + "write failed: %s", vrrpd_conffile, + strerror(errno)); + return (VRRP_EDB); + } } (void) snprintf(newfile, MAXPATHLEN, "%s.new", vrrpd_conffile); @@ -2662,7 +2676,8 @@ vrrpd_enable(const char *vn, boolean_t updateconf) if ((strlen(conf->vvc_link) == 0) || dladm_name2info(vrrpd_vh->vh_dh, conf->vvc_link, NULL, &flags, &class, NULL) != DLADM_STATUS_OK || !(flags & DLADM_OPT_ACTIVE) || ((class != DATALINK_CLASS_PHYS) && - (class != DATALINK_CLASS_VLAN) && (class != DATALINK_CLASS_AGGR))) { + (class != DATALINK_CLASS_VLAN) && (class != DATALINK_CLASS_AGGR) && + (class != DATALINK_CLASS_VNIC))) { vrrp_log(VRRP_DBG1, "vrrpd_enable(%s): invalid link %s", vn, conf->vvc_link); return (VRRP_EINVALLINK); diff --git a/usr/src/lib/libvrrpadm/common/libvrrpadm.c b/usr/src/lib/libvrrpadm/common/libvrrpadm.c index 2e9cb06aaf..15365864a1 100644 --- a/usr/src/lib/libvrrpadm/common/libvrrpadm.c +++ b/usr/src/lib/libvrrpadm/common/libvrrpadm.c @@ -24,6 +24,10 @@ * Use is subject to license terms. */ +/* + * Copyright (c) 2012, Joyent, Inc. All rights reserved. + */ + #include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> @@ -692,7 +696,8 @@ lookup_vnic(dladm_handle_t dh, datalink_id_t vnicid, void *arg) if (vrrp_is_vrrp_vnic(lva->lva_vh, vnicid, &linkid, &vid, &vrid, &af) && lva->lva_vrid == vrid && lva->lva_linkid == linkid && - lva->lva_vid == vid && lva->lva_af == af) { + (lva->lva_vid == VLAN_ID_NONE || lva->lva_vid == vid) && + lva->lva_af == af) { if (dladm_datalink_id2info(dh, vnicid, NULL, NULL, NULL, lva->lva_vnic, sizeof (lva->lva_vnic)) == DLADM_STATUS_OK) { return (DLADM_WALK_TERMINATE); @@ -714,6 +719,7 @@ vrrp_get_vnicname(vrrp_handle_t vh, vrid_t vrid, int af, char *link, uint16_t vid = VLAN_ID_NONE; datalink_class_t class; dladm_vlan_attr_t vlan_attr; + dladm_vnic_attr_t vnic_attr; struct lookup_vnic_arg lva; uint32_t media; @@ -736,11 +742,20 @@ vrrp_get_vnicname(vrrp_handle_t vh, vrid_t vrid, int af, char *link, } } + if (class == DATALINK_CLASS_VNIC) { + if (dladm_vnic_info(vh->vh_dh, linkid, &vnic_attr, + DLADM_OPT_ACTIVE) != DLADM_STATUS_OK) { + return (VRRP_EINVAL); + } + linkid = vnic_attr.va_link_id; + vid = vnic_attr.va_vid; + } + /* - * For now, Only VRRP over aggr and physical ethernet links is supported + * Only VRRP over vnics, aggrs and physical ethernet links is supported */ - if ((class != DATALINK_CLASS_PHYS && class != DATALINK_CLASS_AGGR) || - media != DL_ETHER) { + if ((class != DATALINK_CLASS_PHYS && class != DATALINK_CLASS_AGGR && + class != DATALINK_CLASS_VNIC) || media != DL_ETHER) { return (VRRP_EINVAL); } |