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/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ggsn/+/17812 ) Change subject: sgsnemu: Avoid adding extra autogenerated local link ipv6 addr to tun iface ...................................................................... sgsnemu: Avoid adding extra autogenerated local link ipv6 addr to tun iface It's not needed because a link-local address will be added as a result of Create Pdp Context Response. Morevoer, it fools sgsnemu ip addr verifications since it gets used on some scenarios by applications. Change-Id: I1d51f3ca91edbb3b788939982ab63264182ec2ce --- M sgsnemu/sgsnemu.c 1 file changed, 47 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/12/17812/1 diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c index 22be2fe..f00275e 100644 --- a/sgsnemu/sgsnemu.c +++ b/sgsnemu/sgsnemu.c @@ -46,6 +46,10 @@ #include <resolv.h> #include <time.h> +#if defined(__linux__) +#include <linux/if_link.h> +#endif + #include "config.h" #include "../lib/tun.h" #include "../lib/ippool.h" @@ -999,6 +1003,37 @@ return proc_read(path); } +/* write a single value to a /proc file */ +static int proc_write(const char *path, const char *value) +{ + int ret; + FILE *f; + + f = fopen(path, "w"); + if (!f) { + SYS_ERR(DSGSN, LOGL_ERROR, 0, "fopen(%s) failed!\n", path); + return -1; + } + + if ((ret = fputs(value, f)) < 0) { + SYS_ERR(DSGSN, LOGL_ERROR, 0, "proc_write(%s, %s) failed!\n", path, value); + } else { + ret = 0; + } + fclose(f); + return ret; +} + +/* Write value of to /proc/sys/net/ipv6/conf file for given device. + * Memory is dynamically allocated, caller must free it later. */ +static int proc_ipv6_conf_write(const char *dev, const char *file, const char *value) +{ + const char *fmt = "/proc/sys/net/ipv6/conf/%s/%s"; + char path[strlen(fmt) + strlen(dev) + strlen(file)+1]; + snprintf(path, sizeof(path), fmt, dev, file); + return proc_write(path, value); +} + static char *print_ipprot(int t) { struct protoent *pe = getprotobynumber(t); @@ -1604,6 +1639,7 @@ struct timeval tv; int diff; #if defined(__linux__) + char buf[10]; sigset_t oldmask; #endif @@ -1668,6 +1704,17 @@ "Failed to create tun"); exit(1); } + +#if defined(__linux__) + /* Avoid tunnel setting its own link-local addr automatically, we don't need it. */ + snprintf(buf, sizeof(buf), "%u", IN6_ADDR_GEN_MODE_NONE); + if (proc_ipv6_conf_write(options.tun_dev_name, "addr_gen_mode", buf) < 0) { + SYS_ERR(DSGSN, LOGL_ERROR, errno, + "Failed to disable addr_gen_mode on %s\n", options.tun_dev_name); + exit(1); + } +#endif + tun_set_cb_ind(tun, cb_tun_ind); if (tun->fd > maxfd) maxfd = tun->fd; -- To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/17812 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ggsn Gerrit-Branch: master Gerrit-Change-Id: I1d51f3ca91edbb3b788939982ab63264182ec2ce Gerrit-Change-Number: 17812 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200414/8ce90c63/attachment.htm>