Example #1
0
/* ARGSUSED */
static dladm_status_t
do_set_priority(dladm_handle_t handle, const char *flow, val_desc_t *vdp,
    uint_t val_cnt)
{
	dld_ioc_modifyflow_t	attr;
	mac_resource_props_t	mrp;

	if (val_cnt != 1)
		return (DLADM_STATUS_BADVALCNT);

	bzero(&mrp, sizeof (mrp));
	if (vdp != NULL) {
		bcopy(&vdp->vd_val, &mrp.mrp_priority,
		    sizeof (mac_priority_level_t));
	} else {
		mrp.mrp_priority = MPL_RESET;
	}
	mrp.mrp_mask = MRP_PRIORITY;

	bzero(&attr, sizeof (attr));
	(void) strlcpy(attr.mf_name, flow, sizeof (attr.mf_name));
	bcopy(&mrp, &attr.mf_resource_props, sizeof (mac_resource_props_t));

	if (ioctl(dladm_dld_fd(handle), DLDIOC_MODIFYFLOW, &attr) < 0)
		return (dladm_errno2status(errno));

	return (DLADM_STATUS_OK);
}
Example #2
0
dladm_status_t
dladm_open(dladm_handle_t *handle)
{
	int dld_fd;

	if (handle == NULL)
		return (DLADM_STATUS_BADARG);

	if ((dld_fd = open(DLD_CONTROL_DEV, O_RDWR)) < 0)
		return (dladm_errno2status(errno));

	/*
	 * Don't open DLMGMT_DOOR now.  dlmgmtd(1M) is not able to
	 * open the door when the dladm handle is opened because the
	 * door hasn't been created yet at that time.  Thus, we must
	 * open it on-demand in dladm_door_fd().  Move the open()
	 * to dladm_door_fd() for all cases.
	 */

	if ((*handle = malloc(sizeof (struct dladm_handle))) == NULL) {
		(void) close(dld_fd);
		return (DLADM_STATUS_NOMEM);
	}

	(*handle)->dld_fd = dld_fd;
	(*handle)->door_fd = -1;

	return (DLADM_STATUS_OK);
}
Example #3
0
/* ARGSUSED */
static dladm_status_t
do_set_dscp(dladm_handle_t handle, const char *flow, val_desc_t *vdp,
    uint_t val_cnt)
{
	dld_ioc_modifyflow_t	attr;
	mac_resource_props_t	mrp;
	void			*val;

	if (val_cnt != 1)
		return (DLADM_STATUS_BADVALCNT);

	bzero(&mrp, sizeof (mrp));
	if (vdp != NULL && (val = (void *)vdp->vd_val) != NULL) {
		bcopy(val, &mrp.mrp_dscp, sizeof (int8_t));
		free(val);
	} else {
		mrp.mrp_dscp = MRP_DSCP_RESETVAL;
	}
	mrp.mrp_mask = MRP_DSCP;

	bzero(&attr, sizeof (attr));
	(void) strlcpy(attr.mf_name, flow, sizeof (attr.mf_name));
	bcopy(&mrp, &attr.mf_resource_props, sizeof (mac_resource_props_t));

	if (ioctl(dladm_dld_fd(handle), DLDIOC_MODIFYFLOW, &attr) < 0)
		return (dladm_errno2status(errno));

	return (DLADM_STATUS_OK);
}
Example #4
0
/*
 * If DLMGMT_DOOR hasn't been opened in the handle yet, open it.
 */
dladm_status_t
dladm_door_fd(dladm_handle_t handle, int *door_fd)
{
	int fd;

	if (handle->door_fd == -1) {
		if ((fd = open(DLMGMT_DOOR, O_RDONLY)) < 0)
			return (dladm_errno2status(errno));
		handle->door_fd = fd;
	}
	*door_fd = handle->door_fd;

	return (DLADM_STATUS_OK);
}
Example #5
0
static dladm_status_t
i_dladm_flow_add(dladm_handle_t handle, char *flowname, datalink_id_t linkid,
    flow_desc_t *flowdesc, mac_resource_props_t *mrp)
{
	dld_ioc_addflow_t	attr;

	/* create flow */
	bzero(&attr, sizeof (attr));
	bcopy(flowdesc, &attr.af_flow_desc, sizeof (flow_desc_t));
	if (mrp != NULL) {
		bcopy(mrp, &attr.af_resource_props,
		    sizeof (mac_resource_props_t));
	}

	(void) strlcpy(attr.af_name, flowname, sizeof (attr.af_name));
	attr.af_linkid = linkid;

	if (ioctl(dladm_dld_fd(handle), DLDIOC_ADDFLOW, &attr) < 0)
		return (dladm_errno2status(errno));

	return (DLADM_STATUS_OK);
}