ns2: move link layer type into NSE
Even it was in theory possible to mix NS-VC ll types within
a NSE. This is an unrealistic configuration.
Further more to select the correct load sharing mechanism
the NSE must know the correct link layer.
Change-Id: I18dfd40a2429cd61b7c4a3dad5f226c64296f7d8
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 96ad767..5e43364 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -226,7 +226,7 @@
if (!buf_len)
return NULL;
- switch (nsvc->ll) {
+ switch (nsvc->nse->ll) {
case GPRS_NS2_LL_UDP:
if (!gprs_ns2_is_ip_bind(nsvc->bind)) {
buf[0] = '\0';
@@ -397,15 +397,11 @@
/* signalling */
nsvc = ns2_load_sharing_signal(nse);
} else {
- enum gprs_ns2_ll ll;
-
/* data with load sharing parameter */
if (llist_empty(&nse->nsvc))
return NULL;
- nsvc = llist_first_entry(&nse->nsvc, struct gprs_ns2_vc, list);
- ll = nsvc->ll;
- switch (ll) {
+ switch (nse->ll) {
case GPRS_NS2_LL_FR:
nsvc = ns2_load_sharing_modulor(nse, bvci, link_selector);
break;
@@ -676,7 +672,7 @@
* \param[in] nsi NS instance in which to create NS Entity
* \param[in] nsei NS Entity Identifier of to-be-created NSE
* \returns newly-allocated NS-E in successful case; NULL on error */
-struct gprs_ns2_nse *gprs_ns2_create_nse(struct gprs_ns2_inst *nsi, uint16_t nsei)
+struct gprs_ns2_nse *gprs_ns2_create_nse(struct gprs_ns2_inst *nsi, uint16_t nsei, enum gprs_ns2_ll linklayer)
{
struct gprs_ns2_nse *nse;
@@ -690,6 +686,7 @@
if (!nse)
return NULL;
+ nse->ll = linklayer;
nse->nsei = nsei;
nse->nsi = nsi;
nse->first = true;
@@ -845,7 +842,7 @@
return GPRS_NS2_CS_SKIPPED;
}
- nse = gprs_ns2_create_nse(bind->nsi, nsei);
+ nse = gprs_ns2_create_nse(bind->nsi, nsei, bind->ll);
if (!nse) {
return GPRS_NS2_CS_ERROR;
}
@@ -855,8 +852,6 @@
if (!nsvc)
return GPRS_NS2_CS_SKIPPED;
- nsvc->ll = GPRS_NS2_LL_UDP;
-
nsvci = tlvp_val16be(&tp, NS_IE_VCI);
nsvc->nsvci = nsvci;
nsvc->nsvci_is_valid = true;
@@ -926,7 +921,7 @@
struct gprs_ns2_nse *nse = gprs_ns2_nse_by_nsei(bind->nsi, nsei);
if (!nse) {
- nse = gprs_ns2_create_nse(bind->nsi, nsei);
+ nse = gprs_ns2_create_nse(bind->nsi, nsei, GPRS_NS2_LL_UDP);
if (!nse)
return NULL;
}
@@ -947,7 +942,7 @@
struct gprs_ns2_vc *nsvc;
if (!nse) {
- nse = gprs_ns2_create_nse(bind->nsi, nsei);
+ nse = gprs_ns2_create_nse(bind->nsi, nsei, GPRS_NS2_LL_UDP);
if (!nse)
return -1;
}
diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index 75c70d7..80e3366 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -354,6 +354,7 @@
return -ENOSPC;
bind->driver = &vc_driver_fr;
+ bind->ll = GPRS_NS2_LL_FR;
bind->send_vc = fr_vc_sendmsg;
bind->free_vc = free_vc;
bind->dump_vty = dump_vty;
@@ -469,7 +470,7 @@
struct priv_vc *priv = NULL;
struct gprs_ns2_nse *nse = gprs_ns2_nse_by_nsei(bind->nsi, nsei);
if (!nse) {
- nse = gprs_ns2_create_nse(bind->nsi, nsei);
+ nse = gprs_ns2_create_nse(bind->nsi, nsei, GPRS_NS2_LL_FR);
if (!nse)
return NULL;
created_nse = true;
@@ -490,7 +491,6 @@
nsvc->nsvci = nsvci;
nsvc->nsvci_is_valid = true;
- nsvc->ll = GPRS_NS2_LL_FR;
gprs_ns2_vc_fsm_start(nsvc);
diff --git a/src/gb/gprs_ns2_frgre.c b/src/gb/gprs_ns2_frgre.c
index cd478d6..3c276bc 100644
--- a/src/gb/gprs_ns2_frgre.c
+++ b/src/gb/gprs_ns2_frgre.c
@@ -555,6 +555,7 @@
}
bind->driver = &vc_driver_frgre;
+ bind->ll = GPRS_NS2_LL_FR_GRE;
bind->send_vc = frgre_vc_sendmsg;
bind->free_vc = free_vc;
bind->nsi = nsi;
diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h
index d7211e5..08ffac2 100644
--- a/src/gb/gprs_ns2_internal.h
+++ b/src/gb/gprs_ns2_internal.h
@@ -123,6 +123,9 @@
/*! true if this NSE has at least one alive VC */
bool alive;
+ /*! which link-layer are we based on? */
+ enum gprs_ns2_ll ll;
+
struct osmo_fsm_inst *bss_sns_fi;
};
@@ -164,8 +167,6 @@
struct rate_ctr_group *ctrg;
struct osmo_stat_item_group *statg;
- /*! which link-layer are we based on? */
- enum gprs_ns2_ll ll;
enum gprs_ns2_vc_mode mode;
struct osmo_fsm_inst *fi;
@@ -186,6 +187,9 @@
/*! if VCs use reset/block/unblock method. IP shall not use this */
enum gprs_ns2_vc_mode vc_mode;
+ /*! which link-layer are we based on? */
+ enum gprs_ns2_ll ll;
+
/*! send a msg over a VC */
int (*send_vc)(struct gprs_ns2_vc *nsvc, struct msgb *msg);
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c
index 38c1a16..7f82667 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -322,6 +322,7 @@
}
bind->driver = &vc_driver_ip;
+ bind->ll = GPRS_NS2_LL_UDP;
bind->send_vc = nsip_vc_sendmsg;
bind->free_vc = free_vc;
bind->dump_vty = dump_vty;
@@ -391,8 +392,6 @@
priv = nsvc->priv;
priv->remote = *remote;
- nsvc->ll = GPRS_NS2_LL_UDP;
-
return nsvc;
}
@@ -403,9 +402,6 @@
{
struct priv_bind *priv;
- if (nsvc->ll != GPRS_NS2_LL_UDP)
- return NULL;
-
if (nsvc->bind->driver != &vc_driver_ip)
return NULL;
@@ -420,7 +416,7 @@
{
struct priv_vc *priv;
- if (nsvc->ll != GPRS_NS2_LL_UDP)
+ if (nsvc->bind->driver != &vc_driver_ip)
return NULL;
priv = nsvc->priv;
@@ -442,7 +438,7 @@
struct priv_vc *vpriv;
struct priv_bind *bpriv;
- if (nsvc->ll != GPRS_NS2_LL_UDP)
+ if (nsvc->bind->driver != &vc_driver_ip)
return false;
vpriv = nsvc->priv;
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index fa9b97b..4c00ae3 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -525,11 +525,6 @@
return CMD_WARNING;
}
- if (vtyvc->ll != GPRS_NS2_LL_FR_GRE) {
- vty_out(vty, "Warning: seting FR DLCI on non-FR NSE%s",
- VTY_NEWLINE);
- }
-
vtyvc->frdlci = dlci;
return CMD_SUCCESS;
@@ -880,7 +875,7 @@
nse = gprs_ns2_nse_by_nsei(vty_nsi, vtyvc->nsei);
if (!nse) {
- nse = gprs_ns2_create_nse(vty_nsi, vtyvc->nsei);
+ nse = gprs_ns2_create_nse(vty_nsi, vtyvc->nsei, vtyvc->ll);
if (!nse) {
/* Could not create NSE for VTY */
continue;