summaryrefslogtreecommitdiff
path: root/usr/src/lib/libdlpi/common/libdlpi.c
diff options
context:
space:
mode:
authorSebastien Roy <Sebastien.Roy@Sun.COM>2009-09-22 22:04:45 -0400
committerSebastien Roy <Sebastien.Roy@Sun.COM>2009-09-22 22:04:45 -0400
commit2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea (patch)
tree72c0d7d4e1c44843a86bab6e3ed6f82cfa7356af /usr/src/lib/libdlpi/common/libdlpi.c
parent51fc88a818087605a0e5f11eddb8b66576f72c23 (diff)
downloadillumos-joyent-2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea.tar.gz
PSARC 2009/373 Clearview IP Tunneling
PSARC 2009/410 Datalink Administration from Non-Global Zones 6858533 Clearview IP Tunneling 4861777 *snoop* cannot snoop on tunnel interfaces 5010680 M_IOCTL interface between ip and tun is horribly wrong 5029727 tun prints bogus debug messages when receiving multicast packets on 6to4 tunnels 6835873 dlpi_walk() silently fails in an exclusive zone 4152864 must not allow two tunnels to have the same tsrc/tdst pair 6855902 link and flow kstats are too promiscuous 6218826 need to be able to tunnel into a zone 4505468 network interface names can confuse, lie, and deceive 4524756 tun_wproc() takes up too much stack 6417373 tun_wproc_mdata assertion failures 4627970 scalability problems with IP in IP tunnels 4674797 ifparse_ifspec() will not correctly parse ipv6 tunnels 6509231 dladm should show links in exclusive stack zone 4793233 tun driver should include addr in DL_PHYS_ADDR_ACK for non-zero lengths 6795831 ZONE_*_DATALINK syscalls should take datalink_id_t as argument 6791472 mac module doesn't allow MAC addresses < 6 bytes 6618091 Race condition trips ASSERT() in tun.c's SIOCSLIFNAME path 6837580 bogus mi_active check in mac_set_mtu() 6868083 libinetutil: ofmt_open()'s template argument should be const 6870313 libdladm: needless dladm_init_linkprop() in i_dladm_aggr_up() 6872221 panic in dls_devnet_close() if "mtu" property is being set 4289774 Change to the interface-id does not change IPv6 link-local address 6873561 unable to create links with 31 character link names 6874666 changing a link property can accidentally destroy it 6874682 removing a link attribute corrupts the attribute list 6875167 IPCL_ISV6 conn flag is set but never used 6881764 itp reference leak in ipsec_construct_inverse_acquire() 6881951 dladm delete-vlan can no longer delete persistent-only VLANs --HG-- rename : usr/src/uts/common/inet/tun.h => usr/src/uts/common/inet/iptun.h rename : usr/src/uts/common/inet/ip/tun.c => usr/src/uts/common/inet/iptun/iptun.c rename : usr/src/uts/intel/tun/Makefile => usr/src/uts/intel/iptun/Makefile rename : usr/src/uts/sparc/tun/Makefile => usr/src/uts/sparc/iptun/Makefile
Diffstat (limited to 'usr/src/lib/libdlpi/common/libdlpi.c')
-rw-r--r--usr/src/lib/libdlpi/common/libdlpi.c118
1 files changed, 16 insertions, 102 deletions
diff --git a/usr/src/lib/libdlpi/common/libdlpi.c b/usr/src/lib/libdlpi/common/libdlpi.c
index 2dcf98c90a..bda2648955 100644
--- a/usr/src/lib/libdlpi/common/libdlpi.c
+++ b/usr/src/lib/libdlpi/common/libdlpi.c
@@ -55,7 +55,6 @@ static int i_dlpi_open(const char *, int *, uint_t, boolean_t);
static int i_dlpi_style1_open(dlpi_impl_t *);
static int i_dlpi_style2_open(dlpi_impl_t *);
static int i_dlpi_checkstyle(dlpi_impl_t *, t_uscalar_t);
-static int i_dlpi_remove_ppa(char *);
static int i_dlpi_attach(dlpi_impl_t *);
static void i_dlpi_passive(dlpi_impl_t *);
@@ -134,7 +133,6 @@ int
dlpi_open(const char *linkname, dlpi_handle_t *dhp, uint_t flags)
{
int retval, on = 1;
- int cnt;
ifspec_t ifsp;
dlpi_impl_t *dip;
@@ -166,14 +164,6 @@ dlpi_open(const char *linkname, dlpi_handle_t *dhp, uint_t flags)
if (getenv("DLPI_DEVONLY") != NULL)
dip->dli_oflags |= DLPI_DEVONLY;
- if (!(flags & DLPI_DEVIPNET)) {
- dip->dli_mod_cnt = ifsp.ifsp_modcnt;
- for (cnt = 0; cnt != dip->dli_mod_cnt; cnt++) {
- (void) strlcpy(dip->dli_modlist[cnt],
- ifsp.ifsp_mods[cnt], DLPI_LINKNAME_MAX);
- }
- }
-
/* Copy linkname provided to the function. */
if (strlcpy(dip->dli_linkname, linkname, sizeof (dip->dli_linkname)) >=
sizeof (dip->dli_linkname)) {
@@ -1140,45 +1130,18 @@ i_dlpi_style1_open(dlpi_impl_t *dip)
int retval, save_errno;
int fd;
- /*
- * In order to support open of syntax like device[.module[.module...]]
- * where modules need to be pushed onto the device stream, open only
- * device name, otherwise open the full linkname.
- */
- retval = i_dlpi_open((dip->dli_mod_cnt != 0) ?
- dip->dli_provider : dip->dli_linkname, &fd,
- dip->dli_oflags, B_TRUE);
-
- if (retval != DLPI_SUCCESS) {
- dip->dli_mod_pushed = 0;
+ retval = i_dlpi_open(dip->dli_linkname, &fd, dip->dli_oflags, B_TRUE);
+ if (retval != DLPI_SUCCESS)
return (retval);
- }
dip->dli_fd = fd;
- /*
- * Try to push modules (if any) onto the device stream. If I_PUSH
- * fails, we increment count of modules pushed (dli_mod_pushed)
- * expecting it is last module to be pushed and thus will be pushed
- * in i_dlpi_style2_open().
- */
- for (dip->dli_mod_pushed = 0; dip->dli_mod_pushed < dip->dli_mod_cnt;
- dip->dli_mod_pushed++) {
- if (ioctl(fd, I_PUSH,
- dip->dli_modlist[dip->dli_mod_pushed]) == -1) {
- dip->dli_mod_pushed++;
- return (DLPI_FAILURE);
- }
- }
-
if ((retval = i_dlpi_checkstyle(dip, DL_STYLE1)) != DLPI_SUCCESS) {
save_errno = errno;
(void) close(dip->dli_fd);
errno = save_errno;
- dip->dli_mod_pushed = 0;
- return (retval);
}
- return (DLPI_SUCCESS);
+ return (retval);
}
/*
@@ -1190,45 +1153,10 @@ i_dlpi_style2_open(dlpi_impl_t *dip)
int fd;
int retval, save_errno;
- /*
- * If style 1 open failed, we need to determine how far it got and
- * finish up the open() call as a style 2 open.
- *
- * If no modules were pushed (mod_pushed == 0), then we need to
- * open it as a style 2 link.
- *
- * If the pushing of the last module failed, we need to
- * try pushing it as a style 2 module. Decrement dli_mod_pushed
- * count so it can be pushed onto the stream.
- *
- * Otherwise we failed during the push of an intermediate module and
- * must fail out and close the link.
- */
- if (dip->dli_mod_pushed == 0) {
- if ((retval = i_dlpi_open(dip->dli_provider, &fd,
- dip->dli_oflags, B_FALSE)) != DLPI_SUCCESS) {
- return (retval);
- }
- dip->dli_fd = fd;
- } else if (dip->dli_mod_pushed == dip->dli_mod_cnt) {
- if (i_dlpi_remove_ppa(dip->dli_modlist[dip->dli_mod_cnt - 1])
- != DLPI_SUCCESS)
- return (DLPI_ELINKNAMEINVAL);
-
- dip->dli_mod_pushed--;
- fd = dip->dli_fd;
- } else {
- return (DLPI_ELINKNAMEINVAL);
- }
-
- /* Try and push modules (if any) onto the device stream. */
- for (; dip->dli_mod_pushed < dip->dli_mod_cnt; dip->dli_mod_pushed++) {
- if (ioctl(fd, I_PUSH,
- dip->dli_modlist[dip->dli_mod_pushed]) == -1) {
- retval = DL_SYSERR;
- goto failure;
- }
- }
+ retval = i_dlpi_open(dip->dli_provider, &fd, dip->dli_oflags, B_FALSE);
+ if (retval != DLPI_SUCCESS)
+ return (retval);
+ dip->dli_fd = fd;
/*
* Special case: DLPI_SERIAL flag (synchronous serial lines) is not a
@@ -1248,10 +1176,8 @@ i_dlpi_style2_open(dlpi_impl_t *dip)
return (DLPI_SUCCESS);
attach:
- if ((retval = i_dlpi_attach(dip)) != DLPI_SUCCESS)
- goto failure;
-
- return (DLPI_SUCCESS);
+ if ((retval = i_dlpi_attach(dip)) == DLPI_SUCCESS)
+ return (DLPI_SUCCESS);
failure:
save_errno = errno;
@@ -1278,25 +1204,6 @@ i_dlpi_checkstyle(dlpi_impl_t *dip, t_uscalar_t style)
}
/*
- * Remove PPA from end of linkname.
- * Return DLPI_SUCCESS if found, else return DLPI_FAILURE.
- */
-static int
-i_dlpi_remove_ppa(char *linkname)
-{
- int i = strlen(linkname) - 1;
-
- if (i == -1 || !isdigit(linkname[i--]))
- return (DLPI_FAILURE);
-
- while (i >= 0 && isdigit(linkname[i]))
- i--;
-
- linkname[i + 1] = '\0';
- return (DLPI_SUCCESS);
-}
-
-/*
* For DLPI style 2 providers, an explicit attach of PPA is required.
*/
static int
@@ -1842,6 +1749,13 @@ i_dlpi_notifyind_process(dlpi_impl_t *dip, dl_notify_ind_t *dlnotifyindp)
notifinfo.dni_size = dlnotifyindp->dl_data;
break;
case DL_NOTE_PHYS_ADDR:
+ /*
+ * libdlpi currently only supports notifications for
+ * DL_CURR_PHYS_ADDR.
+ */
+ if (dlnotifyindp->dl_data != DL_CURR_PHYS_ADDR)
+ return (DLPI_ENOTENOTSUP);
+
dataoff = dlnotifyindp->dl_addr_offset;
datalen = dlnotifyindp->dl_addr_length;