aboutgitcodebugslistschat
path: root/udp_flow.c
diff options
context:
space:
mode:
Diffstat (limited to 'udp_flow.c')
-rw-r--r--udp_flow.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/udp_flow.c b/udp_flow.c
index 31e2f8a..5a59f7f 100644
--- a/udp_flow.c
+++ b/udp_flow.c
@@ -64,11 +64,13 @@ void udp_flow_close(const struct ctx *c, struct udp_flow *uflow)
* @c: Execution context
* @uflow: UDP flow to open socket for
* @sidei: Side of @uflow to open socket for
+ * @now: Current timestamp
*
* Return: fd of new socket on success, -ve error code on failure
*/
static int udp_flow_sock(const struct ctx *c,
- struct udp_flow *uflow, unsigned sidei)
+ struct udp_flow *uflow, unsigned sidei,
+ const struct timespec *now)
{
const struct flowside *side = &uflow->f.side[sidei];
uint8_t pif = uflow->f.pif[sidei];
@@ -77,7 +79,8 @@ static int udp_flow_sock(const struct ctx *c,
s = flowside_sock_l4(c, EPOLL_TYPE_UDP, pif, side);
if (s < 0) {
- flow_dbg_perror(uflow, "Couldn't open flow specific socket");
+ flow_perror_ratelimit(uflow, now,
+ "Couldn't open flow specific socket");
return s;
}
@@ -90,11 +93,11 @@ static int udp_flow_sock(const struct ctx *c,
if (flowside_connect(c, s, pif, side) < 0) {
rc = -errno;
- flow_dbg_perror(uflow, "Couldn't connect flow socket");
+ flow_warn_perror_ratelimit(uflow, now,
+ "Couldn't connect flow socket");
epoll_del(flow_epollfd(&uflow->f), s);
close(s);
-
return rc;
}
uflow->s[sidei] = s;
@@ -155,7 +158,7 @@ static flow_sidx_t udp_flow_new(const struct ctx *c, union flow *flow,
flow_foreach_sidei(sidei) {
if (pif_is_socket(uflow->f.pif[sidei]))
- if (udp_flow_sock(c, uflow, sidei) < 0)
+ if (udp_flow_sock(c, uflow, sidei, now) < 0)
goto cancel;
}
@@ -177,7 +180,7 @@ static flow_sidx_t udp_flow_new(const struct ctx *c, union flow *flow,
goto cancel;
}
if (port != tgt->oport) {
- flow_err(uflow, "Unexpected local port");
+ flow_err_ratelimit(uflow, now, "Unexpected local port");
goto cancel;
}
}
@@ -249,7 +252,8 @@ flow_sidx_t udp_flow_from_sock(const struct ctx *c, uint8_t pif,
* been initiated from a socket bound to 0.0.0.0 or ::, we don't
* know our address, so we have to leave it unpopulated.
*/
- flow_err(flow, "Invalid endpoint on UDP recvfrom()");
+ flow_err_ratelimit(flow, now,
+ "Invalid endpoint on UDP recvfrom()");
flow_alloc_cancel(flow);
return FLOW_SIDX_NONE;
}