This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/23976 ) Change subject: ns2: Allow setting the socket priority for a UDP bind ...................................................................... ns2: Allow setting the socket priority for a UDP bind Change-Id: Ifdfa086ce1c8d62b256abb3454b70cf53da9dcdb --- M include/osmocom/gprs/gprs_ns2.h M src/gb/gprs_ns2_udp.c M src/gb/gprs_ns2_vty.c M src/gb/libosmogb.map 4 files changed, 54 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/76/23976/1 diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h index be59a67..a9c144c 100644 --- a/include/osmocom/gprs/gprs_ns2.h +++ b/include/osmocom/gprs/gprs_ns2.h @@ -246,6 +246,7 @@ const struct osmo_sockaddr *gprs_ns2_ip_bind_sockaddr(struct gprs_ns2_vc_bind *bind); int gprs_ns2_is_ip_bind(struct gprs_ns2_vc_bind *bind); int gprs_ns2_ip_bind_set_dscp(struct gprs_ns2_vc_bind *bind, int dscp); +int gprs_ns2_ip_bind_set_priority(struct gprs_ns2_vc_bind *bind, uint8_t priority); struct gprs_ns2_vc *gprs_ns2_nsvc_by_sockaddr_bind( struct gprs_ns2_vc_bind *bind, const struct osmo_sockaddr *saddr); diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c index 0de207c..7980df5 100644 --- a/src/gb/gprs_ns2_udp.c +++ b/src/gb/gprs_ns2_udp.c @@ -49,6 +49,7 @@ struct osmo_fd fd; struct osmo_sockaddr addr; int dscp; + uint8_t priority; }; struct priv_vc { @@ -103,7 +104,8 @@ 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 @@ 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) { diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c index c390423..0fd7c17 100644 --- a/src/gb/gprs_ns2_vty.c +++ b/src/gb/gprs_ns2_vty.c @@ -67,6 +67,7 @@ const char *name; enum gprs_ns2_ll ll; int dscp; + uint8_t priority; bool accept_ipaccess; bool accept_sns; uint8_t ip_sns_sig_weight; @@ -468,6 +469,8 @@ vty_out(vty, " accept-dynamic-ip-sns%s", VTY_NEWLINE); if (vbind->dscp) vty_out(vty, " dscp %u%s", vbind->dscp, VTY_NEWLINE); + if (vbind->priority) + vty_out(vty, " priority %u%s", vbind->priority, VTY_NEWLINE); vty_out(vty, " ip-sns signalling-weight %u data-weight %u%s", vbind->ip_sns_sig_weight, vbind->ip_sns_data_weight, VTY_NEWLINE); break; @@ -722,6 +725,28 @@ return CMD_SUCCESS; } +DEFUN(cfg_ns_bind_priority, cfg_ns_bind_priority_cmd, + "priority <0-255>", + "Set socket priority on the UDP socket\n" "Priority Value (>6 requires CAP_NET_ADMIN)\n") +{ + struct vty_bind *vbind = vty->index; + struct gprs_ns2_vc_bind *bind; + uint8_t prio = atoi(argv[0]); + + if (vbind->ll != GPRS_NS2_LL_UDP) { + vty_out(vty, "dscp can be only used with UDP bind%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + vbind->priority = prio; + bind = gprs_ns2_bind_by_name(vty_nsi, vbind->name); + if (bind) + gprs_ns2_ip_bind_set_priority(bind, prio); + + return CMD_SUCCESS; +} + DEFUN(cfg_ns_bind_ipaccess, cfg_ns_bind_ipaccess_cmd, "accept-ipaccess", "Allow to create dynamic NS Entity by NS Reset PDU on UDP (ip.access style)\n" @@ -2235,6 +2260,7 @@ install_lib_element(L_NS_BIND_NODE, &cfg_no_ns_bind_listen_cmd); install_lib_element(L_NS_BIND_NODE, &cfg_ns_bind_dscp_cmd); install_lib_element(L_NS_BIND_NODE, &cfg_no_ns_bind_dscp_cmd); + install_lib_element(L_NS_BIND_NODE, &cfg_ns_bind_priority_cmd); install_lib_element(L_NS_BIND_NODE, &cfg_ns_bind_ip_sns_weight_cmd); install_lib_element(L_NS_BIND_NODE, &cfg_ns_bind_ipaccess_cmd); install_lib_element(L_NS_BIND_NODE, &cfg_no_ns_bind_ipaccess_cmd); diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map index ed9b822..db638f9 100644 --- a/src/gb/libosmogb.map +++ b/src/gb/libosmogb.map @@ -162,6 +162,7 @@ gprs_ns2_ip_bind; gprs_ns2_ip_bind_by_sockaddr; gprs_ns2_ip_bind_set_dscp; +gprs_ns2_ip_bind_set_priority; gprs_ns2_ip_bind_set_sns_weight; gprs_ns2_ip_bind_sockaddr; gprs_ns2_ip_connect; -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/23976 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ifdfa086ce1c8d62b256abb3454b70cf53da9dcdb Gerrit-Change-Number: 23976 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210429/12b56b6c/attachment.htm>