Change in osmo-bts[master]: osmo-bts-virtual: Add "virtual-um ttl <0-255>" VTY option

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
Tue Mar 10 15:49:01 UTC 2020


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/17443 )


Change subject: osmo-bts-virtual: Add "virtual-um ttl <0-255>" VTY option
......................................................................

osmo-bts-virtual: Add "virtual-um ttl <0-255>" VTY option

This can be used to determine the multicast TTL packet and hence
how far the packet will propagate in the network.  If you want to
operate the virtual Um only on your own machine, a TTL of 0 would
prevent the packets from ever being transmitted on your local
ethernet segment.

Change-Id: I18a9f93b764aee4e1dc68a1c6ac4d078e52ca61d
Related: OS#2966
---
M include/osmo-bts/phy_link.h
M src/osmo-bts-virtual/l1_if.c
M src/osmo-bts-virtual/main.c
M src/osmo-bts-virtual/virtual_um.c
M src/osmo-bts-virtual/virtual_um.h
M src/osmo-bts-virtual/virtualbts_vty.c
6 files changed, 35 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/43/17443/1

diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h
index 69c6bd6..116297b 100644
--- a/include/osmo-bts/phy_link.h
+++ b/include/osmo-bts/phy_link.h
@@ -53,6 +53,7 @@
 		} osmotrx;
 		struct {
 			char *mcast_dev;		/* Network device for multicast */
+			int ttl;			/* TTL of transmitted udp multicast */
 			char *bts_mcast_group;		/* BTS are listening to this group */
 			uint16_t bts_mcast_port;
 			char *ms_mcast_group;		/* MS are listening to this group */
diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c
index b6a3507..3128012 100644
--- a/src/osmo-bts-virtual/l1_if.c
+++ b/src/osmo-bts-virtual/l1_if.c
@@ -204,7 +204,7 @@
 
 	plink->u.virt.virt_um = virt_um_init(plink, plink->u.virt.ms_mcast_group, plink->u.virt.ms_mcast_port,
 					     plink->u.virt.bts_mcast_group, plink->u.virt.bts_mcast_port,
-					     virt_um_rcv_cb);
+					     plink->u.virt.ttl, virt_um_rcv_cb);
 	if (!plink->u.virt.virt_um) {
 		phy_link_state_set(plink, PHY_LINK_SHUTDOWN);
 		return -1;
diff --git a/src/osmo-bts-virtual/main.c b/src/osmo-bts-virtual/main.c
index 02b7ae9..8a2d21c 100644
--- a/src/osmo-bts-virtual/main.c
+++ b/src/osmo-bts-virtual/main.c
@@ -123,6 +123,7 @@
 	plink->u.virt.bts_mcast_port = DEFAULT_BTS_MCAST_PORT;
 	plink->u.virt.ms_mcast_group = talloc_strdup(plink, DEFAULT_MS_MCAST_GROUP);
 	plink->u.virt.ms_mcast_port = DEFAULT_MS_MCAST_PORT;
+	plink->u.virt.ttl = -1;
 }
 
 void bts_model_phy_instance_set_defaults(struct phy_instance *pinst)
diff --git a/src/osmo-bts-virtual/virtual_um.c b/src/osmo-bts-virtual/virtual_um.c
index 752e4b6..e19f9f2 100644
--- a/src/osmo-bts-virtual/virtual_um.c
+++ b/src/osmo-bts-virtual/virtual_um.c
@@ -62,10 +62,12 @@
 }
 
 struct virt_um_inst *virt_um_init(void *ctx, char *tx_mcast_group, uint16_t tx_mcast_port,
-				  char *rx_mcast_group, uint16_t rx_mcast_port,
+				  char *rx_mcast_group, uint16_t rx_mcast_port, int ttl,
 				  void (*recv_cb)(struct virt_um_inst *vui, struct msgb *msg))
 {
 	struct virt_um_inst *vui = talloc_zero(ctx, struct virt_um_inst);
+	int rc;
+
 	vui->mcast_sock = mcast_bidir_sock_setup(ctx, tx_mcast_group, tx_mcast_port,
 						 rx_mcast_group, rx_mcast_port, 1, virt_um_fd_cb, vui);
 	if (!vui->mcast_sock) {
@@ -75,6 +77,16 @@
 	}
 	vui->recv_cb = recv_cb;
 
+	if (ttl >= 0) {
+		rc = osmo_sock_mcast_ttl_set(vui->mcast_sock->tx_ofd.fd, ttl);
+		if (rc < 0) {
+			perror("Cannot set TTL of Virtual Um transmit socket");
+			mcast_bidir_sock_close(vui->mcast_sock);
+			talloc_free(vui);
+			return NULL;
+		}
+	}
+
 	return vui;
 
 }
diff --git a/src/osmo-bts-virtual/virtual_um.h b/src/osmo-bts-virtual/virtual_um.h
index ac098dd..7841c33 100644
--- a/src/osmo-bts-virtual/virtual_um.h
+++ b/src/osmo-bts-virtual/virtual_um.h
@@ -23,7 +23,7 @@
 
 struct virt_um_inst *virt_um_init(
                 void *ctx, char *tx_mcast_group, uint16_t tx_mcast_port,
-                char *rx_mcast_group, uint16_t rx_mcast_port,
+                char *rx_mcast_group, uint16_t rx_mcast_port, int ttl,
                 void (*recv_cb)(struct virt_um_inst *vui, struct msgb *msg));
 
 void virt_um_destroy(struct virt_um_inst *vui);
diff --git a/src/osmo-bts-virtual/virtualbts_vty.c b/src/osmo-bts-virtual/virtualbts_vty.c
index 323222b..46f6f2e 100644
--- a/src/osmo-bts-virtual/virtualbts_vty.c
+++ b/src/osmo-bts-virtual/virtualbts_vty.c
@@ -171,6 +171,23 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_phy_mcast_ttl, cfg_phy_mcast_ttl_cmd,
+	"virtual-um ttl <0-255>",
+	VUM_STR "Configure the TTL for transmitted multicast GSMTAP packets\n")
+{
+	struct phy_link *plink = vty->index;
+
+	if (plink->state != PHY_LINK_SHUTDOWN) {
+		vty_out(vty, "Can only reconfigure a PHY link that is down%s",
+			VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	plink->u.virt.ttl = atoi(argv[0]);
+
+	return CMD_SUCCESS;
+}
+
 int bts_model_vty_init(struct gsm_bts *bts)
 {
 	vty_bts = bts;
@@ -180,6 +197,7 @@
 	install_element(PHY_NODE, &cfg_phy_bts_mcast_group_cmd);
 	install_element(PHY_NODE, &cfg_phy_bts_mcast_port_cmd);
 	install_element(PHY_NODE, &cfg_phy_mcast_dev_cmd);
+	install_element(PHY_NODE, &cfg_phy_mcast_ttl_cmd);
 
 	return 0;
 }

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I18a9f93b764aee4e1dc68a1c6ac4d078e52ca61d
Gerrit-Change-Number: 17443
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/20200310/9a7194bc/attachment.htm>


More information about the gerrit-log mailing list