aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2021-02-08 23:13:12 +0100
committerAlexander Couzens <lynxis@fe80.eu>2021-02-12 03:34:32 +0100
commitc4704769237537478b2671225344aa64ad7bdb60 (patch)
treeaa6f951406bfa900fce0135cbab7beb4e4b28c62 /src
parent855155c6ae9d4452b4cddc6ac711c2946d7b5377 (diff)
gprs_ns2: add signalling & data weights for UDP binds
Allow to assign a signalling and data weight to UDP binds. Those weights will be used when doing dynamic configuration over IP-SNS. This is only the first part which only uses the assigned weights when doing a new SNS configuration. The outgoing change weight procedure will be supported in a later patch when the SNS fsm supports outgoing procedures. Related: SYS#5354 Change-Id: I5133e4229377d44772a9af28628a2bc420fea34b
Diffstat (limited to 'src')
-rw-r--r--src/gb/gprs_ns2.c2
-rw-r--r--src/gb/gprs_ns2_internal.h6
-rw-r--r--src/gb/gprs_ns2_sns.c16
-rw-r--r--src/gb/gprs_ns2_udp.c15
-rw-r--r--src/gb/gprs_ns2_vty.c35
-rw-r--r--src/gb/libosmogb.map1
6 files changed, 71 insertions, 4 deletions
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index ca47934e..99a7415c 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -1409,6 +1409,8 @@ int ns2_bind_alloc(struct gprs_ns2_inst *nsi, const char *name,
return -ENOMEM;
}
+ bind->sns_sig_weight = 1;
+ bind->sns_data_weight = 1;
bind->nsi = nsi;
INIT_LLIST_HEAD(&bind->nsvc);
llist_add(&bind->list, &nsi->binding);
diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h
index ff95c814..88e352a1 100644
--- a/src/gb/gprs_ns2_internal.h
+++ b/src/gb/gprs_ns2_internal.h
@@ -257,6 +257,11 @@ struct gprs_ns2_vc_bind {
void (*dump_vty)(const struct gprs_ns2_vc_bind *bind,
struct vty *vty, bool stats);
+ /*! the IP-SNS signalling weight when doing dynamic configuration */
+ uint8_t sns_sig_weight;
+ /*! the IP-SNS data weight when doing dynamic configuration */
+ uint8_t sns_data_weight;
+
struct osmo_stat_item_group *statg;
};
@@ -352,6 +357,7 @@ struct osmo_fsm_inst *ns2_sns_bss_fsm_alloc(struct gprs_ns2_nse *nse,
const char *id);
void ns2_sns_replace_nsvc(struct gprs_ns2_vc *nsvc);
void ns2_sns_notify_alive(struct gprs_ns2_nse *nse, struct gprs_ns2_vc *nsvc, bool alive);
+void ns2_sns_update_weights(struct gprs_ns2_vc_bind *bind);
/* vc */
struct osmo_fsm_inst *ns2_vc_fsm_alloc(struct gprs_ns2_vc *nsvc,
diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c
index 7b287542..d061eed2 100644
--- a/src/gb/gprs_ns2_sns.c
+++ b/src/gb/gprs_ns2_sns.c
@@ -796,8 +796,8 @@ static void ns2_sns_st_size_onenter(struct osmo_fsm_inst *fi, uint32_t old_state
}
ip4_elems->udp_port = sa->u.sin.sin_port;
- ip4_elems->sig_weight = 2;
- ip4_elems->data_weight = 1;
+ ip4_elems->sig_weight = bind->sns_sig_weight;
+ ip4_elems->data_weight = bind->sns_data_weight;
ip4_elems++;
}
@@ -835,8 +835,8 @@ static void ns2_sns_st_size_onenter(struct osmo_fsm_inst *fi, uint32_t old_state
}
ip6_elems->udp_port = sa->u.sin.sin_port;
- ip6_elems->sig_weight = 2;
- ip6_elems->data_weight = 1;
+ ip6_elems->sig_weight = bind->sns_sig_weight;
+ ip6_elems->data_weight = bind->sns_data_weight;
ip6_elems++;
}
@@ -1810,6 +1810,14 @@ void ns2_sns_notify_alive(struct gprs_ns2_nse *nse, struct gprs_ns2_vc *nsvc, bo
}
}
+/* Update SNS weights
+ * \param[in] nsvc the NSVC which should be updated
+ */
+void ns2_sns_update_weights(struct gprs_ns2_vc_bind *bind)
+{
+ /* TODO: implement weights after binds per sns implemented */
+}
+
/* initialize osmo_ctx on main tread */
static __attribute__((constructor)) void on_dso_load_ctx(void)
{
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c
index e07f6d43..0f224583 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -104,6 +104,8 @@ static void dump_vty(const struct gprs_ns2_vc_bind *bind,
}
vty_out(vty, "UDP bind: %s:%d DSCP: %d%s", sockstr.ip, sockstr.port, priv->dscp, 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);
llist_for_each_entry(nsvc, &bind->nsvc, blist) {
@@ -567,3 +569,16 @@ struct gprs_ns2_vc_bind *ns2_ip_get_bind_by_index(struct gprs_ns2_inst *nsi,
return NULL;
}
+
+/*! set the signalling and data weight for this bind
+ * \param[in] bind
+ * \param[in] signalling the signalling weight
+ * \param[in] data the data weight
+ */
+void gprs_ns2_ip_bind_set_sns_weight(struct gprs_ns2_vc_bind *bind, uint8_t signalling, uint8_t data)
+{
+ OSMO_ASSERT(gprs_ns2_is_ip_bind(bind));
+ bind->sns_sig_weight = signalling;
+ bind->sns_data_weight = data;
+ ns2_sns_update_weights(bind);
+}
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 36460802..55f88b15 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -66,6 +66,8 @@ struct vty_bind {
int dscp;
bool accept_ipaccess;
bool accept_sns;
+ uint8_t ip_sns_sig_weight;
+ uint8_t ip_sns_data_weight;
};
/* TODO: this should into osmo timer */
@@ -118,6 +120,8 @@ static struct vty_bind *vty_bind_alloc(const char *name)
return NULL;
}
+ vbind->ip_sns_sig_weight = 1;
+ vbind->ip_sns_data_weight = 1;
llist_add(&vbind->list, &binds);
return vbind;
}
@@ -328,6 +332,8 @@ static void config_write_vbind(struct vty *vty, struct vty_bind *vbind)
vty_out(vty, " accept-ipaccess%s", VTY_NEWLINE);
if (vbind->dscp)
vty_out(vty, " dscp %u%s", vbind->dscp, 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;
default:
return;
@@ -611,6 +617,34 @@ DEFUN(cfg_no_ns_bind_ipaccess, cfg_no_ns_bind_ipaccess_cmd,
return CMD_SUCCESS;
}
+DEFUN(cfg_ns_bind_ip_sns_weight, cfg_ns_bind_ip_sns_weight_cmd,
+ "ip-sns signalling-weight <0-254> data-weight <0-254>",
+ "IP SNS\n"
+ "signalling weight used by IP-SNS dynamic configuration\n"
+ "signalling weight used by IP-SNS dynamic configuration\n"
+ "data weight used by IP-SNS dynamic configuration\n"
+ "data weight used by IP-SNS dynamic configuration\n")
+{
+ struct vty_bind *vbind = vty->index;
+ struct gprs_ns2_vc_bind *bind;
+
+ int signalling = atoi(argv[0]);
+ int data = atoi(argv[1]);
+
+ if (vbind->ll != GPRS_NS2_LL_UDP) {
+ vty_out(vty, "ip-sns signalling-weight <0-254> data-weight <0-254> can be only used with UDP bind%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ vbind->ip_sns_data_weight = data;
+ vbind->ip_sns_sig_weight = signalling;
+ bind = gprs_ns2_bind_by_name(vty_nsi, vbind->name);
+ if (bind)
+ gprs_ns2_ip_bind_set_sns_weight(bind, signalling, data);
+
+ return CMD_SUCCESS;
+}
DEFUN(cfg_ns_bind_fr, cfg_ns_bind_fr_cmd,
"fr NETIF (fr|frnet)",
@@ -1686,6 +1720,7 @@ int gprs_ns2_vty_init(struct gprs_ns2_inst *nsi)
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_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);
install_lib_element(L_NS_BIND_NODE, &cfg_ns_bind_fr_cmd);
diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map
index a3171d0c..7da11cda 100644
--- a/src/gb/libosmogb.map
+++ b/src/gb/libosmogb.map
@@ -158,6 +158,7 @@ gprs_ns2_instantiate;
gprs_ns2_ip_bind;
gprs_ns2_ip_bind_by_sockaddr;
gprs_ns2_ip_bind_set_dscp;
+gprs_ns2_ip_bind_set_sns_weight;
gprs_ns2_ip_bind_sockaddr;
gprs_ns2_ip_connect;
gprs_ns2_ip_connect2;