Socket Level Properties
Starting with the Oracle Solaris 11.2 release, you can use the
SO_FLOW_SLA
option to set the service-level properties for
the socket. A socket application using the SO_FLOW_SLA
socket
option causes the system to create a system flow, which is an enforcement mechanism
for the service-level properties. You can use flowadm
to observe
the system flows. For more information, see the
flowadm
(8) man page. These system flows have the prefix
<id>.sys.sock
.
The pfiles
prints the SO_FLOW_SLA
socket
option with other socket options. For more information, see the
pfiles
(1) man page.
Note:
You can set the socket level properties only forTCP
and
UDP
sockets.
The usage of SO_FLOW_SLA
socket option is described in the
following example.
#include <sys/types.h> #include <sys/socket.h> extern struct sockaddr *serv_addr; int fd; mac_flow_props_t mprop; mac_flow_props_t mprop_result; fd = socket(AF_INET, SOCK_STREAM, 0); mprop.mfp_version = MAC_FLOW_PROP_VERSION1; mprop.mfp_mask = MFP_MAXBW | MFP_PRIORITY; mprop.mfp_priority = MFP_PRIO_HIGH; mprop.mfp_maxbw = 100000000; /* in bits per second */ setsockopt(fd, SOL_SOCKET, SO_FLOW_SLA, &mprop, sizeof (mprop)); connect(fd, serv_addr, sizeof(*serv_addr)); getsockopt(fd, SOL_SOCKET, SO_FLOW_SLA, &mprop_result, sizeof (mprop_result));
In the example, the TCP
client socket is created along with the
system flow. The flow is set to a high priority and the maximum bandwidth is set to
100Mbps.
The system flow is created for the socket by calling connect
()
or accept
()
functions after setsockopt
. If
either accept
()
or connect
()
function is
already called, setting SO_FLOW_SLA
will create a flow.
Properties of the flow are set according to the values specified in
mac_flow_props_t
structure. This structure is passed as a
pointer to setsockopt
as an optval
argument. You can know the status of the flow creation by using
getsockopt
. The status is stored in the
mprop_result.mfp_status
field. The
mac_flow_props_t
structure is defined as follows.
typedef struct mac_flow_props_s { int mfp_version; uint32_t mfp_mask; int mfp_priority; /* flow priority */ uint64_t mfp_maxbw; /* bandwidth limit in bps */ int mfp_status; /* flow create status for getsockopt */ } mac_flow_props_t;
The following list describes the fields of the mac_flow_props_t
structure.
-
mfp_version
-
Denotes the version of the
mac_flow_props_t
structure. Currently,mfp_version
can only be set to 1.#define MAC_FLOW_PROP_VERSION1
-
mfp_mask
-
Denotes the bit mask values. The following bit mask values are valid.
-
MRP_MAXBW
-
MRP_PRIORITY
-
-
mfp_priority
-
Denotes the priority of processing the packets that belong to the socket. The following priority values are valid.
-
MFP_PRIO_NORMAL
-
MFP_PRIO_HIGH
-
-
mfp_maxbw
-
Denotes the maximum bandwidth allotted to the socket in bits per second. Value of 0 means all the packets of socket must be dropped.
-
mfp_status
-
Denotes the status of the flow creation. You can obtain the status of flow creation by calling
getsockopt
.getsockopt
sets themfp_status
field. A value of 0 means a flow is successfully created. In case of an error, this field is set to one of the following error codes.-
EPERM
: No Privilege.
-
ENOTCONN
: If the call is made before the application does a connect or bind.
-
EOPNOTSUPP
: Flow creation is not supported for this socket.
-
EALREADY
: Flow with identical attributes exists.
-
EINPROGRESS
: Flow is being created.
-