Change in libosmocore[master]: gprs_ns2: add signalling & data weights for UDP binds

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/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Fri Feb 12 00:21:10 UTC 2021


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/22868 )


Change subject: gprs_ns2: add signalling & data weights for UDP binds
......................................................................

gprs_ns2: add signalling & data weights for UDP binds

Allow to assign a signalling and date weight to UDP binds.
Those weights will be use when doing dynamic configuration over
IP-SNS.
This is only the first part which only use 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 support outgoing procedures.

Change-Id: I5133e4229377d44772a9af28628a2bc420fea34b
---
M include/osmocom/gprs/gprs_ns2.h
M src/gb/gprs_ns2.c
M src/gb/gprs_ns2_internal.h
M src/gb/gprs_ns2_sns.c
M src/gb/gprs_ns2_udp.c
M src/gb/gprs_ns2_vty.c
M tests/gb/gprs_ns2_vty.vty
7 files changed, 73 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/68/22868/1

diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h
index 1bf8c7f..07e6c45 100644
--- a/include/osmocom/gprs/gprs_ns2.h
+++ b/include/osmocom/gprs/gprs_ns2.h
@@ -215,6 +215,8 @@
 					const struct osmo_sockaddr *remote,
 					struct gprs_ns2_nse *nse,
 					uint16_t nsvci);
+void gprs_ns2_ip_bind_set_sns_weight(struct gprs_ns2_vc_bind *bind,
+				     uint8_t signalling, uint8_t data);
 
 void gprs_ns2_free_bind(struct gprs_ns2_vc_bind *bind);
 void gprs_ns2_free_binds(struct gprs_ns2_inst *nsi);
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index ca47934..f86f3a3 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -1409,6 +1409,8 @@
 		return -ENOMEM;
 	}
 
+	bind->sns_signalling_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 ff95c81..53f809b 100644
--- a/src/gb/gprs_ns2_internal.h
+++ b/src/gb/gprs_ns2_internal.h
@@ -257,6 +257,11 @@
 	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_signalling_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 @@
 					     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_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 7b28754..9e77f2a 100644
--- a/src/gb/gprs_ns2_sns.c
+++ b/src/gb/gprs_ns2_sns.c
@@ -796,8 +796,8 @@
 			}
 
 			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_signalling_weight;
+			ip4_elems->data_weight = bind->sns_data_weight;
 			ip4_elems++;
 		}
 
@@ -835,8 +835,8 @@
 			}
 
 			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_signalling_weight;
+			ip6_elems->data_weight = bind->sns_data_weight;
 
 			ip6_elems++;
 		}
@@ -1810,6 +1810,14 @@
 	}
 }
 
+/* Update SNS weights
+ * \param[in] nsvc the NSVC which should be updated
+ */
+void ns2_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 e07f6d4..cf48f7a 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -104,6 +104,8 @@
 	}
 
 	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_signalling_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 @@
 
 	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_signalling_weight = signalling;
+	bind->sns_data_weight = data;
+	/* TODO: inform the sns fsms of all nsvcs/nse about it */
+}
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 3646080..a5e282e 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -66,6 +66,8 @@
 	int dscp;
 	bool accept_ipaccess;
 	bool accept_sns;
+	uint8_t ip_sns_signalling_weight;
+	uint8_t ip_sns_data_weight;
 };
 
 /* TODO: this should into osmo timer */
@@ -118,6 +120,8 @@
 		return NULL;
 	}
 
+	vbind->ip_sns_signalling_weight = 1;
+	vbind->ip_sns_data_weight = 1;
 	llist_add(&vbind->list, &binds);
 	return vbind;
 }
@@ -328,6 +332,8 @@
 			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_signalling_weight, vbind->ip_sns_data_weight, VTY_NEWLINE);
 		break;
 	default:
 		return;
@@ -611,6 +617,34 @@
 	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_signalling_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 @@
 	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/tests/gb/gprs_ns2_vty.vty b/tests/gb/gprs_ns2_vty.vty
index 397ec26..a748f13 100644
--- a/tests/gb/gprs_ns2_vty.vty
+++ b/tests/gb/gprs_ns2_vty.vty
@@ -30,4 +30,5 @@
 OsmoNSdummy(config-ns-bind)# end
 OsmoNSdummy# show ns
 UDP bind: 127.0.0.14:42999 DSCP: 0
+  IP-SNS signalling weight: 1 data weight: 1
   0 NS-VC: 

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/22868
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I5133e4229377d44772a9af28628a2bc420fea34b
Gerrit-Change-Number: 22868
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210212/47c3117c/attachment.htm>


More information about the gerrit-log mailing list