diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-01-19 11:46:11 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-01-19 11:46:11 +0000 |
commit | 9b8ca9c9263a1b4ec9973cd82da03522c09ab892 (patch) | |
tree | 746e4ddb5373e5f9c263dd5f5a9f3f2b640c2649 /usr.sbin/dvmrpd | |
parent | ed714005bdde9178a68c4321460e4e1238532335 (diff) |
Another pkt_ptr cleanup. There is actually no need to make the pkt
a static memory region. Just use the stack.
Diffstat (limited to 'usr.sbin/dvmrpd')
-rw-r--r-- | usr.sbin/dvmrpd/dvmrpd.h | 3 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/dvmrpe.c | 6 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/dvmrpe.h | 4 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/packet.c | 9 |
4 files changed, 8 insertions, 14 deletions
diff --git a/usr.sbin/dvmrpd/dvmrpd.h b/usr.sbin/dvmrpd/dvmrpd.h index a8cf93ff399..511ccdc9d84 100644 --- a/usr.sbin/dvmrpd/dvmrpd.h +++ b/usr.sbin/dvmrpd/dvmrpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpd.h,v 1.22 2016/09/02 16:20:34 benno Exp $ */ +/* $OpenBSD: dvmrpd.h,v 1.23 2021/01/19 11:46:10 claudio Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org> @@ -39,6 +39,7 @@ #define NBR_IDSELF 1 #define NBR_CNTSTART (NBR_IDSELF + 1) +#define READ_BUF_SIZE 65535 #define RT_BUF_SIZE 16384 #define DVMRPD_FLAG_NO_FIB_UPDATE 0x0001 diff --git a/usr.sbin/dvmrpd/dvmrpe.c b/usr.sbin/dvmrpd/dvmrpe.c index 76e232b833e..6b2c11daf9b 100644 --- a/usr.sbin/dvmrpd/dvmrpe.c +++ b/usr.sbin/dvmrpd/dvmrpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpe.c,v 1.19 2016/09/02 16:20:34 benno Exp $ */ +/* $OpenBSD: dvmrpe.c,v 1.20 2021/01/19 11:46:10 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -170,9 +170,6 @@ dvmrpe(struct dvmrpd_conf *xconf, int pipe_parent2dvmrpe[2], TAILQ_INIT(&ctl_conns); control_listen(); - if ((pkt_ptr = calloc(1, IBUF_READ_SIZE)) == NULL) - fatal("dvmrpe"); - /* start interfaces */ LIST_FOREACH(iface, &deconf->iface_list, entry) { if_init(xconf, iface); @@ -216,7 +213,6 @@ dvmrpe_shutdown(void) /* clean up */ free(iev_rde); free(iev_main); - free(pkt_ptr); log_info("dvmrp engine exiting"); _exit(0); diff --git a/usr.sbin/dvmrpd/dvmrpe.h b/usr.sbin/dvmrpd/dvmrpe.h index c1cd384bc77..031d2bca627 100644 --- a/usr.sbin/dvmrpd/dvmrpe.h +++ b/usr.sbin/dvmrpd/dvmrpe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpe.h,v 1.5 2014/10/25 03:23:49 lteo Exp $ */ +/* $OpenBSD: dvmrpe.h,v 1.6 2021/01/19 11:46:10 claudio Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org> @@ -186,8 +186,6 @@ int gen_dvmrp_hdr(struct ibuf *, struct iface *, u_int8_t); int send_packet(struct iface *, void *, size_t, struct sockaddr_in *); void recv_packet(int, short, void *); -char *pkt_ptr; /* packet buffer */ - /* probe.c */ int send_probe(struct iface *); void recv_probe(struct iface *, struct in_addr, u_int32_t, u_int8_t, diff --git a/usr.sbin/dvmrpd/packet.c b/usr.sbin/dvmrpd/packet.c index b88716b70a6..757598c82d6 100644 --- a/usr.sbin/dvmrpd/packet.c +++ b/usr.sbin/dvmrpd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.5 2015/12/07 19:14:49 mmcc Exp $ */ +/* $OpenBSD: packet.c,v 1.6 2021/01/19 11:46:10 claudio Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org> @@ -97,6 +97,7 @@ recv_packet(int fd, short event, void *bula) struct nbr *nbr = NULL; struct in_addr addr; char *buf; + char pkt[READ_BUF_SIZE]; ssize_t r; u_int16_t len; int l; @@ -104,16 +105,14 @@ recv_packet(int fd, short event, void *bula) if (event != EV_READ) return; - /* setup buffer */ - buf = pkt_ptr; - - if ((r = recvfrom(fd, buf, IBUF_READ_SIZE, 0, NULL, NULL)) == -1) { + if ((r = recvfrom(fd, pkt, sizeof(pkt), 0, NULL, NULL)) == -1) { if (errno != EAGAIN && errno != EINTR) log_debug("recv_packet: error receiving packet"); return; } len = (u_int16_t)r; + buf = pkt; /* IP header sanity checks */ if (len < sizeof(ip_hdr)) { |