Commits

Stephen Hemminger authored and Paul Jakma committed 4c699477d24
[zebra:linux] netlink: no need to change privs for receive

2008-06-17 Stephen Hemminger <stephen.hemminger@vyatta.com> * rt_netlink.c: (netlink_parse_info) Linux doesn't check privledges on receive, so avoid the overhead of lowering and raising the priviledges on each received message Signed-off-by: Paul Jakma <paul@quagga.net>
No tags

zebra/rt_netlink.c

Modified
278 278 int ret = 0;
279 279 int error;
280 280
281 281 while (1)
282 282 {
283 283 char buf[4096];
284 284 struct iovec iov = { buf, sizeof buf };
285 285 struct sockaddr_nl snl;
286 286 struct msghdr msg = { (void *) &snl, sizeof snl, &iov, 1, NULL, 0, 0 };
287 287 struct nlmsghdr *h;
288 - int save_errno;
289 -
290 - if (zserv_privs.change (ZPRIVS_RAISE))
291 - zlog (NULL, LOG_ERR, "Can't raise privileges");
292 288
293 289 status = recvmsg (nl->sock, &msg, 0);
294 - save_errno = errno;
295 -
296 - if (zserv_privs.change (ZPRIVS_LOWER))
297 - zlog (NULL, LOG_ERR, "Can't lower privileges");
298 -
299 290 if (status < 0)
300 291 {
301 - if (save_errno == EINTR)
292 + if (errno == EINTR)
302 293 continue;
303 - if (save_errno == EWOULDBLOCK || save_errno == EAGAIN)
294 + if (errno == EWOULDBLOCK || errno == EAGAIN)
304 295 break;
305 296 zlog (NULL, LOG_ERR, "%s recvmsg overrun: %s",
306 - nl->name, safe_strerror(save_errno));
297 + nl->name, safe_strerror(errno));
307 298 continue;
308 299 }
309 300
310 301 if (status == 0)
311 302 {
312 303 zlog (NULL, LOG_ERR, "%s EOF", nl->name);
313 304 return -1;
314 305 }
315 306
316 307 if (msg.msg_namelen != sizeof snl)

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut