Is there a way to call ioctl (the question is also valid for all sys calls) with commands SIOCGIFFLAGS
and SIOCSIFFLAGS
in an atomic manner? For example if i would add the IFF_PROMISC
flag to an interface:
...
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, "eth0");
if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0)
...
ifr.ifr_flags |= IFF_PROMISC;
if (ioctl(sk, SIOCSIFFLAGS, &ifr) < 0)
...
how can i ensure that these two calls are made atomically?
Thank you all!