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

laforge gerrit-no-reply at lists.osmocom.org
Fri Feb 12 08:57:16 UTC 2021


laforge has submitted this change. ( 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 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
---
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 src/gb/libosmogb.map
M tests/gb/gprs_ns2_vty.vty
8 files changed, 74 insertions(+), 4 deletions(-)

Approvals:
  daniel: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



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..99a7415 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -1409,6 +1409,8 @@
 		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 ff95c81..88e352a 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_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 @@
 					     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 7b28754..d061eed 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_sig_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_sig_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_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 e07f6d4..0f22458 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_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 @@
 
 	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 3646080..55f88b1 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_sig_weight;
+	uint8_t ip_sns_data_weight;
 };
 
 /* TODO: this should into osmo timer */
@@ -118,6 +120,8 @@
 		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 @@
 			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 @@
 	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 @@
 	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 a3171d0..7da11cd 100644
--- a/src/gb/libosmogb.map
+++ b/src/gb/libosmogb.map
@@ -158,6 +158,7 @@
 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;
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: 3
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210212/87c44018/attachment.htm>


More information about the gerrit-log mailing list