summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorgfaden <none@none>2008-02-25 17:23:19 -0800
committergfaden <none@none>2008-02-25 17:23:19 -0800
commitde860bd9529e1034e1666f74f7bc0ec8cd5ca701 (patch)
tree4895a1aa39176716fe2f6d72b766dea48a96c8b1 /usr/src
parent321febde881fb7f55caa9bc4766f121ff16cd65e (diff)
downloadillumos-gate-de860bd9529e1034e1666f74f7bc0ec8cd5ca701.tar.gz
6583565 need a mechanism to configure a per zone default route in shared IP stack for TX
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/zoneadmd/vplat.c24
-rw-r--r--usr/src/cmd/zonecfg/zonecfg.c59
-rw-r--r--usr/src/cmd/zonecfg/zonecfg.h5
-rw-r--r--usr/src/cmd/zonecfg/zonecfg_grammar.y7
-rw-r--r--usr/src/cmd/zonecfg/zonecfg_lex.l5
-rw-r--r--usr/src/head/libzonecfg.h1
-rw-r--r--usr/src/lib/libzonecfg/common/libzonecfg.c16
-rw-r--r--usr/src/lib/libzonecfg/dtd/zonecfg.dtd.13
8 files changed, 105 insertions, 15 deletions
diff --git a/usr/src/cmd/zoneadmd/vplat.c b/usr/src/cmd/zoneadmd/vplat.c
index 59225164a6..1b5f4da8be 100644
--- a/usr/src/cmd/zoneadmd/vplat.c
+++ b/usr/src/cmd/zoneadmd/vplat.c
@@ -2476,6 +2476,30 @@ configure_one_interface(zlog_t *zlogp, zoneid_t zone_id,
lifr.lifr_name, addrstr4, buffer);
}
+ /*
+ * If a default router was specified for this interface
+ * set the route now. Ignore if already set.
+ */
+ if (strlen(nwiftabptr->zone_nwif_defrouter) > 0) {
+ int status;
+ char *argv[7];
+
+ argv[0] = "route";
+ argv[1] = "add";
+ argv[2] = "-ifp";
+ argv[3] = nwiftabptr->zone_nwif_physical;
+ argv[4] = "default";
+ argv[5] = nwiftabptr->zone_nwif_defrouter;
+ argv[6] = NULL;
+
+ status = forkexec(zlogp, "/usr/sbin/route", argv);
+ if (status != 0 && status != EEXIST)
+ zerror(zlogp, B_FALSE, "Unable to set route for "
+ "interface %s to %s\n",
+ nwiftabptr->zone_nwif_physical,
+ nwiftabptr->zone_nwif_defrouter);
+ }
+
(void) close(s);
return (Z_OK);
bad:
diff --git a/usr/src/cmd/zonecfg/zonecfg.c b/usr/src/cmd/zonecfg/zonecfg.c
index 500e644a7a..90ddd247ce 100644
--- a/usr/src/cmd/zonecfg/zonecfg.c
+++ b/usr/src/cmd/zonecfg/zonecfg.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -220,6 +220,7 @@ static char *prop_types[] = {
ALIAS_MAXSWAP,
"scheduling-class",
"ip-type",
+ "defrouter",
NULL
};
@@ -936,10 +937,13 @@ usage(bool verbose, uint_t flags)
pt_to_str(PT_PHYSICAL), gettext("<interface>"));
(void) fprintf(fp, gettext("See ifconfig(1M) for "
"details of the <interface> string.\n"));
- (void) fprintf(fp, gettext("%s %s is valid if the %s "
- "property is set to %s, otherwise it must not be "
- "set.\n"),
+ (void) fprintf(fp, "\t%s %s=%s\n", cmd_to_str(CMD_SET),
+ pt_to_str(PT_DEFROUTER), gettext("<IP-address>"));
+ (void) fprintf(fp, gettext("%s %s and %s %s are valid "
+ "if the %s property is set to %s, otherwise they "
+ "must not be set.\n"),
cmd_to_str(CMD_SET), pt_to_str(PT_ADDRESS),
+ cmd_to_str(CMD_SET), pt_to_str(PT_DEFROUTER),
pt_to_str(PT_IPTYPE), "shared");
break;
case RT_DEVICE:
@@ -1155,8 +1159,9 @@ usage(bool verbose, uint_t flags)
pt_to_str(PT_OPTIONS));
(void) fprintf(fp, "\t%s\t%s\n", rt_to_str(RT_IPD),
pt_to_str(PT_DIR));
- (void) fprintf(fp, "\t%s\t\t%s, %s\n", rt_to_str(RT_NET),
- pt_to_str(PT_ADDRESS), pt_to_str(PT_PHYSICAL));
+ (void) fprintf(fp, "\t%s\t\t%s, %s, %s\n", rt_to_str(RT_NET),
+ pt_to_str(PT_ADDRESS), pt_to_str(PT_PHYSICAL),
+ pt_to_str(PT_DEFROUTER));
(void) fprintf(fp, "\t%s\t\t%s\n", rt_to_str(RT_DEVICE),
pt_to_str(PT_MATCH));
(void) fprintf(fp, "\t%s\t\t%s, %s\n", rt_to_str(RT_RCTL),
@@ -1779,6 +1784,7 @@ export_func(cmd_t *cmd)
rt_to_str(RT_NET));
export_prop(of, PT_ADDRESS, nwiftab.zone_nwif_address);
export_prop(of, PT_PHYSICAL, nwiftab.zone_nwif_physical);
+ export_prop(of, PT_DEFROUTER, nwiftab.zone_nwif_defrouter);
(void) fprintf(of, "%s\n", cmd_to_str(CMD_END));
}
(void) zonecfg_endnwifent(handle);
@@ -2550,6 +2556,11 @@ fill_in_nwiftab(cmd_t *cmd, struct zone_nwiftab *nwiftab, bool fill_in_only)
pp->pv_simple,
sizeof (nwiftab->zone_nwif_physical));
break;
+ case PT_DEFROUTER:
+ (void) strlcpy(nwiftab->zone_nwif_defrouter,
+ pp->pv_simple,
+ sizeof (nwiftab->zone_nwif_defrouter));
+ break;
default:
zone_perror(pt_to_str(cmd->cmd_prop_name[i]),
Z_NO_PROPERTY_TYPE, TRUE);
@@ -3297,6 +3308,18 @@ remove_property(cmd_t *cmd)
zone_perror(pt_to_str(prop_type), err, TRUE);
zonecfg_free_rctl_value_list(rctlvaltab);
return;
+ case RT_NET:
+ if (prop_type != PT_DEFROUTER) {
+ zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
+ TRUE);
+ long_usage(CMD_REMOVE, TRUE);
+ usage(FALSE, HELP_PROPS);
+ return;
+ } else {
+ bzero(&in_progress_nwiftab.zone_nwif_defrouter,
+ sizeof (in_progress_nwiftab.zone_nwif_defrouter));
+ return;
+ }
default:
zone_perror(rt_to_str(res_type), Z_NO_RESOURCE_TYPE, TRUE);
long_usage(CMD_REMOVE, TRUE);
@@ -4159,6 +4182,15 @@ set_func(cmd_t *cmd)
prop_id,
sizeof (in_progress_nwiftab.zone_nwif_physical));
break;
+ case PT_DEFROUTER:
+ if (validate_net_address_syntax(prop_id) != Z_OK) {
+ saw_error = TRUE;
+ return;
+ }
+ (void) strlcpy(in_progress_nwiftab.zone_nwif_defrouter,
+ prop_id,
+ sizeof (in_progress_nwiftab.zone_nwif_defrouter));
+ break;
default:
zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
TRUE);
@@ -4688,6 +4720,7 @@ output_net(FILE *fp, struct zone_nwiftab *nwiftab)
(void) fprintf(fp, "%s:\n", rt_to_str(RT_NET));
output_prop(fp, PT_ADDRESS, nwiftab->zone_nwif_address, B_TRUE);
output_prop(fp, PT_PHYSICAL, nwiftab->zone_nwif_physical, B_TRUE);
+ output_prop(fp, PT_DEFROUTER, nwiftab->zone_nwif_defrouter, B_TRUE);
}
static void
@@ -5457,8 +5490,10 @@ verify_func(cmd_t *cmd)
while (zonecfg_getnwifent(handle, &nwiftab) == Z_OK) {
/*
* physical is required in all cases.
- * A shared IP requires an address, while
- * an exclusive IP must not have an address.
+ * A shared IP requires an address,
+ * and may include a default router, while
+ * an exclusive IP must have neither an address
+ * nor a default router.
*/
check_reqd_prop(nwiftab.zone_nwif_physical, RT_NET,
PT_PHYSICAL, &ret_val);
@@ -5477,6 +5512,14 @@ verify_func(cmd_t *cmd)
if (ret_val == Z_OK)
ret_val = Z_INVAL;
}
+ if (strlen(nwiftab.zone_nwif_defrouter) > 0) {
+ zerr(gettext("%s: %s cannot be specified "
+ "for an exclusive IP type"),
+ rt_to_str(RT_NET), pt_to_str(PT_DEFROUTER));
+ saw_error = TRUE;
+ if (ret_val == Z_OK)
+ ret_val = Z_INVAL;
+ }
break;
}
}
diff --git a/usr/src/cmd/zonecfg/zonecfg.h b/usr/src/cmd/zonecfg/zonecfg.h
index 3369012438..e050facfff 100644
--- a/usr/src/cmd/zonecfg/zonecfg.h
+++ b/usr/src/cmd/zonecfg/zonecfg.h
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -135,9 +135,10 @@ typedef int bool;
#define PT_MAXSWAP 32
#define PT_SCHED 33
#define PT_IPTYPE 34
+#define PT_DEFROUTER 35
#define PT_MIN PT_UNKNOWN
-#define PT_MAX PT_IPTYPE
+#define PT_MAX PT_DEFROUTER
#define MAX_EQ_PROP_PAIRS 3
diff --git a/usr/src/cmd/zonecfg/zonecfg_grammar.y b/usr/src/cmd/zonecfg/zonecfg_grammar.y
index 69fc6d98bd..c28a1dda90 100644
--- a/usr/src/cmd/zonecfg/zonecfg_grammar.y
+++ b/usr/src/cmd/zonecfg/zonecfg_grammar.y
@@ -21,7 +21,7 @@
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -63,7 +63,7 @@ extern void yyerror(char *s);
%token NAME MATCH PRIV LIMIT ACTION VALUE EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
%token OPEN_PAREN CLOSE_PAREN COMMA DATASET LIMITPRIV BOOTARGS BRAND PSET PCAP
%token MCAP NCPUS IMPORTANCE SHARES MAXLWPS MAXSHMMEM MAXSHMIDS MAXMSGIDS
-%token MAXSEMIDS LOCKED SWAP SCHED CLEAR
+%token MAXSEMIDS LOCKED SWAP SCHED CLEAR DEFROUTER
%type <strval> TOKEN EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
property_value OPEN_PAREN CLOSE_PAREN COMMA simple_prop_val
@@ -71,7 +71,7 @@ extern void yyerror(char *s);
%type <ival> resource_type NET FS IPD DEVICE RCTL ATTR DATASET PSET PCAP MCAP
%type <ival> property_name SPECIAL RAW DIR OPTIONS TYPE ADDRESS PHYSICAL NAME
MATCH ZONENAME ZONEPATH AUTOBOOT POOL LIMITPRIV BOOTARGS VALUE PRIV LIMIT
- ACTION BRAND SCHED IPTYPE
+ ACTION BRAND SCHED IPTYPE DEFROUTER
%type <cmd> command
%type <cmd> add_command ADD
%type <cmd> cancel_command CANCEL
@@ -865,6 +865,7 @@ property_name: SPECIAL { $$ = PT_SPECIAL; }
| BOOTARGS { $$ = PT_BOOTARGS; }
| ADDRESS { $$ = PT_ADDRESS; }
| PHYSICAL { $$ = PT_PHYSICAL; }
+ | DEFROUTER { $$ = PT_DEFROUTER; }
| NAME { $$ = PT_NAME; }
| VALUE { $$ = PT_VALUE; }
| MATCH { $$ = PT_MATCH; }
diff --git a/usr/src/cmd/zonecfg/zonecfg_lex.l b/usr/src/cmd/zonecfg/zonecfg_lex.l
index 9b8bc81295..0ba7fe5363 100644
--- a/usr/src/cmd/zonecfg/zonecfg_lex.l
+++ b/usr/src/cmd/zonecfg/zonecfg_lex.l
@@ -21,7 +21,7 @@
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -213,6 +213,9 @@ char *safe_strdup(char *s);
<TSTATE>physical { return PHYSICAL; }
<CSTATE>physical { return PHYSICAL; }
+<TSTATE>defrouter { return DEFROUTER; }
+<CSTATE>defrouter { return DEFROUTER; }
+
<TSTATE>dir { return DIR; }
<CSTATE>dir { return DIR; }
diff --git a/usr/src/head/libzonecfg.h b/usr/src/head/libzonecfg.h
index ec122addda..6f1cfe8bde 100644
--- a/usr/src/head/libzonecfg.h
+++ b/usr/src/head/libzonecfg.h
@@ -185,6 +185,7 @@ struct zone_fstab {
struct zone_nwiftab {
char zone_nwif_address[INET6_ADDRSTRLEN];
char zone_nwif_physical[LIFNAMSIZ];
+ char zone_nwif_defrouter[INET6_ADDRSTRLEN];
};
struct zone_devtab {
diff --git a/usr/src/lib/libzonecfg/common/libzonecfg.c b/usr/src/lib/libzonecfg/common/libzonecfg.c
index 2bce66d3f5..025ef86b36 100644
--- a/usr/src/lib/libzonecfg/common/libzonecfg.c
+++ b/usr/src/lib/libzonecfg/common/libzonecfg.c
@@ -96,6 +96,7 @@
#define DTD_ATTR_ADDRESS (const xmlChar *) "address"
#define DTD_ATTR_AUTOBOOT (const xmlChar *) "autoboot"
#define DTD_ATTR_IPTYPE (const xmlChar *) "ip-type"
+#define DTD_ATTR_DEFROUTER (const xmlChar *) "defrouter"
#define DTD_ATTR_DIR (const xmlChar *) "directory"
#define DTD_ATTR_LIMIT (const xmlChar *) "limit"
#define DTD_ATTR_LIMITPRIV (const xmlChar *) "limitpriv"
@@ -2209,6 +2210,11 @@ zonecfg_lookup_nwif(zone_dochandle_t handle, struct zone_nwiftab *tabptr)
sizeof (tabptr->zone_nwif_address))) != Z_OK)
return (err);
+ if ((err = fetchprop(cur, DTD_ATTR_DEFROUTER,
+ tabptr->zone_nwif_defrouter,
+ sizeof (tabptr->zone_nwif_defrouter))) != Z_OK)
+ return (err);
+
return (Z_OK);
}
@@ -2225,6 +2231,9 @@ zonecfg_add_nwif_core(zone_dochandle_t handle, struct zone_nwiftab *tabptr)
if ((err = newprop(newnode, DTD_ATTR_PHYSICAL,
tabptr->zone_nwif_physical)) != Z_OK)
return (err);
+ if ((err = newprop(newnode, DTD_ATTR_DEFROUTER,
+ tabptr->zone_nwif_defrouter)) != Z_OK)
+ return (err);
return (Z_OK);
}
@@ -4386,6 +4395,13 @@ zonecfg_getnwifent(zone_dochandle_t handle, struct zone_nwiftab *tabptr)
return (err);
}
+ if ((err = fetchprop(cur, DTD_ATTR_DEFROUTER,
+ tabptr->zone_nwif_defrouter,
+ sizeof (tabptr->zone_nwif_defrouter))) != Z_OK) {
+ handle->zone_dh_cur = handle->zone_dh_top;
+ return (err);
+ }
+
handle->zone_dh_cur = cur->next;
return (Z_OK);
}
diff --git a/usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1 b/usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1
index 5de8176c42..e650c1cc96 100644
--- a/usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1
+++ b/usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1
@@ -20,7 +20,7 @@
CDDL HEADER END
- Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ Copyright 2008 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
ident "%Z%%M% %I% %E% SMI"
@@ -45,6 +45,7 @@
<!ELEMENT network EMPTY>
<!ATTLIST network address CDATA ""
+ defrouter CDATA ""
physical CDATA #REQUIRED>
<!ELEMENT device EMPTY>