Apply a patch from upstream to fix a warning on startup:

fcntl(8, F_SETFL): Operation not permitted
This commit is contained in:
jasper 2013-07-15 19:12:07 +00:00
parent b3d2c78490
commit 17fe163fd3
4 changed files with 131 additions and 1 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.2 2013/07/13 11:54:36 sthen Exp $
# $OpenBSD: Makefile,v 1.3 2013/07/15 19:12:07 jasper Exp $
COMMENT= LLDP (802.1ab)/CDP/EDP/SONMP/FDP daemon and SNMP subagent
DISTNAME= lldpd-0.7.6
REVISION= 0
SHARED_LIBS += lldpctl 0.0 # 1.0

View File

@ -0,0 +1,86 @@
$OpenBSD: patch-src_daemon_event_c,v 1.1 2013/07/15 19:12:07 jasper Exp $
From bec75f842fa401558a72d62bfbee04bc726407d6 Mon Sep 17 00:00:00 2001
From: Vincent Bernat <bernat@luffy.cx>
Date: Mon, 15 Jul 2013 20:56:00 +0200
Subject: [PATCH] event: replace `evutil_make_socket_nonblocking()` by an
idempotent version
https://github.com/vincentbernat/lldpd/commit/bec75f842fa401558a72d62bfbee04bc726407d6
--- src/daemon/event.c.orig Sat Jun 8 14:35:53 2013
+++ src/daemon/event.c Mon Jul 15 21:07:28 2013
@@ -21,6 +21,7 @@
#include <signal.h>
#include <errno.h>
#include <time.h>
+#include <fcntl.h>
#include <event2/event.h>
#include <event2/bufferevent.h>
#include <event2/buffer.h>
@@ -104,7 +105,7 @@ levent_snmp_add_fd(struct lldpd *cfg, int fd)
log_warn("event", "unable to allocate memory for new SNMP event");
return;
}
- evutil_make_socket_nonblocking(fd);
+ levent_make_socket_nonblocking(fd);
if ((snmpfd->ev = event_new(base, fd,
EV_READ | EV_PERSIST,
levent_snmp_read,
@@ -358,7 +359,7 @@ levent_ctl_accept(evutil_socket_t fd, short what, void
goto accept_failed;
}
client->cfg = cfg;
- evutil_make_socket_nonblocking(s);
+ levent_make_socket_nonblocking(s);
TAILQ_INSERT_TAIL(&lldpd_clients, client, next);
if ((client->bev = bufferevent_socket_new(cfg->g_base, s,
BEV_OPT_CLOSE_ON_FREE)) == NULL) {
@@ -458,7 +459,7 @@ levent_init(struct lldpd *cfg)
/* Setup unix socket */
log_debug("event", "register Unix socket");
TAILQ_INIT(&lldpd_clients);
- evutil_make_socket_nonblocking(cfg->g_ctl);
+ levent_make_socket_nonblocking(cfg->g_ctl);
if ((cfg->g_ctl_event = event_new(cfg->g_base, cfg->g_ctl,
EV_READ|EV_PERSIST, levent_ctl_accept, cfg)) == NULL)
fatalx("unable to setup control socket event");
@@ -547,7 +548,7 @@ levent_hardware_add_fd(struct lldpd_hardware *hardware
hardware->h_ifname);
return;
}
- evutil_make_socket_nonblocking(fd);
+ levent_make_socket_nonblocking(fd);
if ((hfd->ev = event_new(hardware->h_cfg->g_base, fd,
EV_READ | EV_PERSIST,
levent_hardware_recv,
@@ -647,7 +648,7 @@ levent_iface_subscribe(struct lldpd *cfg, int socket)
{
log_debug("event", "subscribe to interface changes from socket %d",
socket);
- evutil_make_socket_nonblocking(socket);
+ levent_make_socket_nonblocking(socket);
cfg->g_iface_event = event_new(cfg->g_base, socket,
EV_READ | EV_PERSIST, levent_iface_recv, cfg);
if (cfg->g_iface_event == NULL) {
@@ -762,4 +763,20 @@ levent_schedule_pdu(struct lldpd_hardware *hardware)
hardware->h_timer = NULL;
return;
}
+}
+
+int
+levent_make_socket_nonblocking(int fd)
+{
+ int flags;
+ if ((flags = fcntl(fd, F_GETFL, NULL)) < 0) {
+ log_warn("event", "fcntl(%d, F_GETFL)", fd);
+ return -1;
+ }
+ if (flags & O_NONBLOCK) return 0;
+ if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) {
+ log_warn("event", "fcntl(%d, F_SETFL)", fd);
+ return -1;
+ }
+ return 0;
}

View File

@ -0,0 +1,20 @@
$OpenBSD: patch-src_daemon_lldpd_h,v 1.1 2013/07/15 19:12:07 jasper Exp $
From bec75f842fa401558a72d62bfbee04bc726407d6 Mon Sep 17 00:00:00 2001
From: Vincent Bernat <bernat@luffy.cx>
Date: Mon, 15 Jul 2013 20:56:00 +0200
Subject: [PATCH] event: replace `evutil_make_socket_nonblocking()` by an
idempotent version
https://github.com/vincentbernat/lldpd/commit/bec75f842fa401558a72d62bfbee04bc726407d6
--- src/daemon/lldpd.h.orig Thu Jul 11 23:13:26 2013
+++ src/daemon/lldpd.h Mon Jul 15 21:07:28 2013
@@ -150,6 +150,7 @@ void levent_update_now(struct lldpd *);
int levent_iface_subscribe(struct lldpd *, int);
void levent_schedule_pdu(struct lldpd_hardware *);
void levent_schedule_cleanup(struct lldpd *);
+int levent_make_socket_nonblocking(int);
/* lldp.c */
int lldp_send(PROTO_SEND_SIG);

View File

@ -0,0 +1,23 @@
$OpenBSD: patch-src_daemon_priv-bsd_c,v 1.1 2013/07/15 19:12:07 jasper Exp $
From bec75f842fa401558a72d62bfbee04bc726407d6 Mon Sep 17 00:00:00 2001
From: Vincent Bernat <bernat@luffy.cx>
Date: Mon, 15 Jul 2013 20:56:00 +0200
Subject: [PATCH] event: replace `evutil_make_socket_nonblocking()` by an
idempotent version
https://github.com/vincentbernat/lldpd/commit/bec75f842fa401558a72d62bfbee04bc726407d6
--- src/daemon/priv-bsd.c.orig Wed Jul 3 22:36:43 2013
+++ src/daemon/priv-bsd.c Mon Jul 15 21:07:28 2013
@@ -125,7 +125,9 @@ asroot_iface_init_os(int ifindex, char *name, int *fd)
#endif
#ifdef BIOCLOCK
- /* Lock interface */
+ /* Lock interface, but first make it non blocking since we cannot do
+ * this later */
+ levent_make_socket_nonblocking(*fd);
if (ioctl(*fd, BIOCLOCK, (caddr_t)&enable) < 0) {
rc = errno;
log_info("privsep", "unable to lock BPF interface %s",