Link Aggregation using the SIOCSLAGG ioctl request

Has anyone made use of the SIOCSLAGG or the SIOCSLAGGPORT ioctl requests to successfully create a link aggregation? I am trying to avoid the use of the ifconfig command of course, but I keep getting an "Invalid Argument" error returned back to me.

Any help with some example code to create a link, mention the link protocol and addition of ports to the link will be of big help.
 
Fails to list aggregations through SIOCGLAGG ioctl request

I am seeing the same behavior with SIOCGLAGG as well now. I have already created a lagg (with 1 interface) through ifconfig. # ifconfig lagg1 create# ifconfig lagg1 laggproto lacp laggport em0 1.1.1.1 netmask 255.255.255.0

But I am unable to fetch this created interface through the get ioctl request.
I am really stuck for ideas now and I maybe missing a very minor detail. Any suggestions will be of big help.
Following is my code snippet, in case you can spot any error in the ioctl invocation..
Code:
struct lagg_reqall lagg_allr = {0};

/*Create the Socket for the ioctl*/
int s = socket(AF_INET, SOCK_DGRAM, 0);
if(s == -1)
	return -1;
	
/*Copy an existing Link Aggregate's name*/
/*lagg1 used here already exists and is UP and Running*/
strcpy(lagg_allr.ra_ifname, "lagg1");

lagg_portr.ra_size = LAGG_MAX_PORTS*sizeof(struct lagg_reqport);
lagg_portr.ra_port = (struct lagg_reqport *)malloc(lagg_portr.ra_size);
memset(lagg_portr.ra_port, 0, lagg_portr.ra_size);
lagg_portr.ra_ports = LAGG_MAX_PORTS;

if(ioctl(s, SIOCGLAGG, (caddr_t)&lagg_portr) == -1) {
        printf("SIOCGLAGG FAILURE: %d\n", errno);
	free(lagg_portr.ra_port);
	return -1;
}

/*Read the whole Info...*/

Worst case is to make use of the system API and pass the whole ifconfig command as a string parameter to it or parse the conf file to get the results.
 
Back
Top