aboutsummaryrefslogtreecommitdiffstats
path: root/src/gb/gprs_ns2_udp.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-04-28 19:57:12 +0200
committerHarald Welte <laforge@osmocom.org>2021-04-29 19:55:34 +0200
commitd99e4eee2b602e3b878398e2fffafc2b7c97081b (patch)
treea15d4ace0897c6f283864728af62fd866862b591 /src/gb/gprs_ns2_udp.c
parent915caf75e24632084b16ff5e45d247da1b6f169e (diff)
ns2: Allow setting the socket priority for a UDP bind
Diffstat (limited to 'src/gb/gprs_ns2_udp.c')
-rw-r--r--src/gb/gprs_ns2_udp.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c
index 0de207c7..7980df59 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -49,6 +49,7 @@ struct priv_bind {
struct osmo_fd fd;
struct osmo_sockaddr addr;
int dscp;
+ uint8_t priority;
};
struct priv_vc {
@@ -103,7 +104,8 @@ static void dump_vty(const struct gprs_ns2_vc_bind *bind,
nsvcs++;
}
- vty_out(vty, "UDP bind: %s:%d DSCP: %d%s", sockstr.ip, sockstr.port, priv->dscp, VTY_NEWLINE);
+ vty_out(vty, "UDP bind: %s:%d DSCP: %d Priority: %u%s", sockstr.ip, sockstr.port,
+ priv->dscp, priv->priority, VTY_NEWLINE);
vty_out(vty, " IP-SNS signalling weight: %u data weight: %u%s",
bind->sns_sig_weight, bind->sns_data_weight, VTY_NEWLINE);
vty_out(vty, " %lu NS-VC:%s", nsvcs, VTY_NEWLINE);
@@ -525,6 +527,29 @@ int gprs_ns2_ip_bind_set_dscp(struct gprs_ns2_vc_bind *bind, int dscp)
return rc;
}
+/*! Set the socket priority of the given bind. */
+int gprs_ns2_ip_bind_set_priority(struct gprs_ns2_vc_bind *bind, uint8_t priority)
+{
+ struct priv_bind *priv;
+ int rc = 0;
+
+ OSMO_ASSERT(gprs_ns2_is_ip_bind(bind));
+ priv = bind->priv;
+
+ if (priority != priv->priority) {
+ priv->priority = priority;
+
+ rc = osmo_sock_set_priority(priv->fd.fd, priority);
+ if (rc < 0) {
+ LOGBIND(bind, LOGL_ERROR, "Failed to set the priority to %u with ret(%d) errno(%d)\n",
+ priority, rc, errno);
+ }
+ }
+
+ return rc;
+}
+
+
/*! Count UDP binds compatible with remote */
int ns2_ip_count_bind(struct gprs_ns2_inst *nsi, struct osmo_sockaddr *remote)
{