Use osmo_fd_setup() whenever applicable

Change-Id: Id6cbb0058b9eb400d69f556232bbe112f257775b
changes/65/20765/1
Harald Welte 2 years ago
parent ca8ef91e0f
commit 0e7068f40c
  1. 5
      src/l2tpd.c
  2. 8
      src/l2tpd_socket.c

@ -88,10 +88,7 @@ static int l2tpd_instance_start(struct l2tpd_instance *li)
INIT_LLIST_HEAD(&li->connections);
li->l2tp_ofd.when = OSMO_FD_READ;
li->l2tp_ofd.cb = l2tp_ip_read_cb;
li->l2tp_ofd.data = li;
osmo_fd_setup(&li->l2tp_ofd, -1, OSMO_FD_READ, l2tp_ip_read_cb, li, 0);
rc = osmo_sock_init_ofd(&li->l2tp_ofd, AF_INET, SOCK_RAW,
IPPROTO_L2TP, li->cfg.bind_ip, 0, 0);
if (rc < 0)

@ -83,9 +83,7 @@ static int l2tp_sock_accept(struct osmo_fd *bfd, unsigned int flags)
return 0;
}
conn_bfd->fd = rc;
conn_bfd->when = OSMO_FD_READ;
osmo_fd_setup(conn_bfd, rc, OSMO_FD_READ, conn_bfd->cb, conn_bfd->data, conn_bfd->priv_nr);
if (osmo_fd_register(conn_bfd) != 0) {
LOGP(state->log_class, LOGL_ERROR, "Failed to register new connection fd\n");
close(conn_bfd->fd);
@ -142,9 +140,7 @@ int l2tp_socket_init(struct l2tp_socket_state *state, const char *sock_path, int
return -1;
}
bfd->when = OSMO_FD_READ;
bfd->cb = l2tp_sock_accept;
osmo_fd_setup(bfd, bfd->fd, OSMO_FD_READ, l2tp_sock_accept, NULL, 0);
rc = osmo_fd_register(bfd);
if (rc < 0) {
LOGP(state->log_class, LOGL_ERROR, "Could not register listen fd: %d\n", rc);

Loading…
Cancel
Save