lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

January 2025

  • 1 participants
  • 1491 discussions
[S] Change in osmo-ttcn3-hacks[master]: testenv: run: add --autoreconf-in-src-copy arg
by osmith 22 Jan '25

22 Jan '25
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/39405?usp=email ) Change subject: testenv: run: add --autoreconf-in-src-copy arg ...................................................................... testenv: run: add --autoreconf-in-src-copy arg Add a new argument that avoids the problem that ./configure refuses to run if it has already been executed in the source dir. (It aborts and asks the user to run "make distclean" first, which is especially annoying if it has to be done in multiple source dirs before being able to build successfully.) Put the new logic behind am "experimental argument" for now. I think it improves usability greatly and plan to make it the default later when it has been well tested. I have also considered making the source dir read-only when mounted into podman and this argument is set. This was the original goal of Lynxis' related patch, on which idea this one is based. But osmo-dev still needs to write into the source dir in case it clones a new repository, so making the sources dir read-only with this trade-off should be a separate flag and could be added in another patch later. Related: osmo-ttcn3-hacks I0f1ac8852218f158ece14c176f05574f60d9d1f7 Depends: osmo-dev I18ac50e3441df81e1fe7d8d5321df7e80ab9c650 Change-Id: I5c38ce69dc39823d12be574c74a654d2fa6ed8fb --- M _testenv/testenv/__init__.py M _testenv/testenv/osmo_dev.py 2 files changed, 17 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/05/39405/1 diff --git a/_testenv/testenv/__init__.py b/_testenv/testenv/__init__.py index c1991ca..4a925bb 100644 --- a/_testenv/testenv/__init__.py +++ b/_testenv/testenv/__init__.py @@ -170,6 +170,14 @@ default=ccache_dir_default, ) + group = sub_run.add_argument_group("experimental options") + group.add_argument( + "-A", + "--autoreconf-in-src-copy", + action="store_true", + help="run autoreconf in a copy of the source dir, avoids 'run make distclean' errors", + ) + sub.add_parser("clean", help="clean previous build artifacts") args = parser.parse_args() diff --git a/_testenv/testenv/osmo_dev.py b/_testenv/testenv/osmo_dev.py index 51d07a7..8748b93 100644 --- a/_testenv/testenv/osmo_dev.py +++ b/_testenv/testenv/osmo_dev.py @@ -73,6 +73,15 @@ os.path.join(testenv.args.cache, "host/usr"), ] + if testenv.args.autoreconf_in_src_copy: + # Use a different make dir, so we don't have unexpected behavior when + # the user already ran autoreconf or ./configure through osmo-dev with + # the previous make dir, without --autoreconf-in-src-copy. + make_dir += "2" + extra_opts += [ + "--autoreconf-in-src-copy", + ] + cmd = [ "./gen_makefile.py", "--build-debug", -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/39405?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I5c38ce69dc39823d12be574c74a654d2fa6ed8fb Gerrit-Change-Number: 39405 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-dev[master]: gen_makefile: fix f-string without placeholders
by osmith 22 Jan '25

22 Jan '25
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-dev/+/39401?usp=email ) Change subject: gen_makefile: fix f-string without placeholders ...................................................................... gen_makefile: fix f-string without placeholders gen_makefile.py:604:17: F541 [*] f-string without any placeholders Change-Id: I77b38247fb38136f77f89d40669b2df378dca192 --- M gen_makefile.py 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/01/39401/1 diff --git a/gen_makefile.py b/gen_makefile.py index 18af686..7d73df8 100755 --- a/gen_makefile.py +++ b/gen_makefile.py @@ -601,7 +601,7 @@ ldconfig_without_sudo=' \\\n\t\t--ldconfig-without-sudo' if args.ldconfig_without_sudo else '', make_check='' if args.make_check else " \\\n\t\t--no-make-check", docker_cmd=f' \\\n\t\t--docker-cmd "{args.docker_cmd}"' if args.docker_cmd else '', - build_debug=f' \\\n\t\t--build-debug' if args.build_debug else '', + build_debug=' \\\n\t\t--build-debug' if args.build_debug else '', auto_distclean=' \\\n\t\t--auto-distclean' if args.auto_distclean else '', ) -- To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/39401?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-Change-Id: I77b38247fb38136f77f89d40669b2df378dca192 Gerrit-Change-Number: 39401 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-dev[master]: ruff.toml: new file
by osmith 22 Jan '25

22 Jan '25
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-dev/+/39399?usp=email ) Change subject: ruff.toml: new file ...................................................................... ruff.toml: new file Add a ruff.toml config, so "ruff check" can be used in a local pre-commit hook to find errors like the following. I'll fix them in follow-up patches. Only checking gen_makefile.py for now as I plan to modify that in follow-up patches. gen_makefile.py:147:7: F841 Local variable `l` is assigned to but never used | 145 | def extend_dict(self, d): 146 | for k,v in d.items(): 147 | l = self.extend(k, v) | ^ F841 148 | 149 | def read_projects_deps(path): | = help: Remove assignment to unused variable `l` Change-Id: If045f3bfc12b333d3426e558294346da83521466 --- A .ruff.toml 1 file changed, 12 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/99/39399/1 diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..64ca401 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,12 @@ +line-length = 120 +exclude = [ + "cgit/osmo-commit-filter.py", + "net/fill_config.py", + "net/templates/freeswitch/python/dialplan-dgsm/__init__.py", + "osmo-cn-latest/provision-hlr.py", + "sysmobts-calib.py", +] + +[lint] +# E741: Ambiguous variable name: `l` +ignore = ["E741"] -- To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/39399?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-Change-Id: If045f3bfc12b333d3426e558294346da83521466 Gerrit-Change-Number: 39399 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-dev[master]: gen_makefile: fix variable assigned but never used
by osmith 22 Jan '25

22 Jan '25
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-dev/+/39400?usp=email ) Change subject: gen_makefile: fix variable assigned but never used ...................................................................... gen_makefile: fix variable assigned but never used gen_makefile.py:147:7: F841 Local variable `l` is assigned to but never used gen_makefile.py:313:5: F841 Local variable `target` is assigned to but never used Change-Id: Ib938d3336d395bfed3e5194dcf86ae5d56f99984 --- M gen_makefile.py 1 file changed, 1 insertion(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/00/39400/1 diff --git a/gen_makefile.py b/gen_makefile.py index 22882bd..18af686 100755 --- a/gen_makefile.py +++ b/gen_makefile.py @@ -144,7 +144,7 @@ def extend_dict(self, d): for k,v in d.items(): - l = self.extend(k, v) + self.extend(k, v) def read_projects_deps(path): 'Read deps config and return tuples of (project_name, which-other-to-build-first).' @@ -310,7 +310,6 @@ touch $@ ''' elif buildsystem == "meson": - target = "test" if check else "compile" test_line = "" # TODO: currently tests don't pass in this env # if check: -- To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/39400?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-Change-Id: Ib938d3336d395bfed3e5194dcf86ae5d56f99984 Gerrit-Change-Number: 39400 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-dev[master]: gen_makefile: modernize generator for "regen"
by osmith 22 Jan '25

22 Jan '25
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-dev/+/39402?usp=email ) Change subject: gen_makefile: modernize generator for "regen" ...................................................................... gen_makefile: modernize generator for "regen" Use f-string instead of .format() to make it more maintainable. Change-Id: I345d2ae64a0afd5fe71d483c7dfe6a2ce2248c74 --- M gen_makefile.py 1 file changed, 50 insertions(+), 50 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/02/39402/1 diff --git a/gen_makefile.py b/gen_makefile.py index 7d73df8..4a4748c 100755 --- a/gen_makefile.py +++ b/gen_makefile.py @@ -513,45 +513,45 @@ configure_opts_args += f' \\\n\t\t{os.path.relpath(f, make_dir)}' # convenience: add a regen target that updates the generated makefile itself -content += r''' +content += f''' default: usrp # # Convenience targets for whole networks # .PHONY: cn -cn: \ - osmo-ggsn \ - osmo-hlr \ - osmo-iuh \ - osmo-mgw \ - osmo-msc \ - osmo-sgsn \ - osmo-sip-connector \ - osmo-smlc \ +cn: \\ + osmo-ggsn \\ + osmo-hlr \\ + osmo-iuh \\ + osmo-mgw \\ + osmo-msc \\ + osmo-sgsn \\ + osmo-sip-connector \\ + osmo-smlc \\ $(NULL) .PHONY: cn-bsc -cn-bsc: \ - cn \ - osmo-bsc \ +cn-bsc: \\ + cn \\ + osmo-bsc \\ $(NULL) .PHONY: cn-bsc-nat -cn-bsc-nat: \ - cn \ - mobile \ - osmo-bsc \ - osmo-bsc-nat \ - osmo-bts \ - virtphy \ +cn-bsc-nat: \\ + cn \\ + mobile \\ + osmo-bsc \\ + osmo-bsc-nat \\ + osmo-bts \\ + virtphy \\ $(NULL) .PHONY: usrp -usrp: \ - cn-bsc \ - osmo-bts \ - osmo-trx \ +usrp: \\ + cn-bsc \\ + osmo-bts \\ + osmo-trx \\ $(NULL) # @@ -577,33 +577,33 @@ # regenerate this Makefile, in case the deps or opts changed .PHONY: regen regen: - {script} \ - {configure_opts} \ - --output {makefile} \ - --src-dir {src_dir} \ - --make-dir {make_dir} \ - --build-dir {build_dir} \ - --jobs {jobs} \ - --url "{url}"{push_url}{sudo_make_install}{no_ldconfig}{ldconfig_without_sudo}{make_check}{docker_cmd}{build_debug}{auto_distclean} + {os.path.relpath(sys.argv[0], make_dir)} \\ + {configure_opts_args} \\ + --output {args.output} \\ + --src-dir {os.path.relpath(args.src_dir, make_dir)} \\ + --make-dir . \\ + --build-dir {os.path.relpath(build_dir, make_dir)} \\ + --jobs {args.jobs} \\ + --url "{args.url}" \\ +''' -'''.format( - script=os.path.relpath(sys.argv[0], make_dir), - configure_opts=configure_opts_args, - make_dir='.', - makefile=args.output, - src_dir=os.path.relpath(args.src_dir, make_dir), - build_dir=os.path.relpath(build_dir, make_dir), - jobs=args.jobs, - url=args.url, - push_url=(" \\\n\t\t--push-url '%s'"%args.push_url) if args.push_url else '', - sudo_make_install=' \\\n\t\t--sudo-make-install' if args.sudo_make_install else '', - no_ldconfig=' \\\n\t\t--no-ldconfig' if args.no_ldconfig else '', - ldconfig_without_sudo=' \\\n\t\t--ldconfig-without-sudo' if args.ldconfig_without_sudo else '', - make_check='' if args.make_check else " \\\n\t\t--no-make-check", - docker_cmd=f' \\\n\t\t--docker-cmd "{args.docker_cmd}"' if args.docker_cmd else '', - build_debug=' \\\n\t\t--build-debug' if args.build_debug else '', - auto_distclean=' \\\n\t\t--auto-distclean' if args.auto_distclean else '', -) +if args.push_url: + content += f" --push-url {shlex.quote(args.push_url)} \\\n" +if args.sudo_make_install: + content += " --sudo-make-install \\\n" +if args.no_ldconfig: + content += " --no-ldconfig \\\n" +if args.ldconfig_without_sudo: + content += " --ldconfig-without-sudo \\\n" +if not args.make_check: + content += " --no-make-check \\\n" +if args.docker_cmd: + content += f" --push-url {shlex.quote(args.docker_cmd)} \\\n" +if args.build_debug: + content += " --build-debug \\\n" +if args.auto_distclean: + content += " --auto-distclean \\\n" +content += " $(NULL)\n" # convenience target: clone all repositories first content += 'clone: \\\n\t' + ' \\\n\t'.join([ '.make.%s.clone' % p for p, d in projects_deps ]) + '\n\n' -- To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/39402?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-Change-Id: I345d2ae64a0afd5fe71d483c7dfe6a2ce2248c74 Gerrit-Change-Number: 39402 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-dev[master]: gen_makefile: add --autoreconf-in-src-copy arg
by osmith 22 Jan '25

22 Jan '25
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-dev/+/39404?usp=email ) Change subject: gen_makefile: add --autoreconf-in-src-copy arg ...................................................................... gen_makefile: add --autoreconf-in-src-copy arg When this new argument is set, do not run "autoreconf -fi" directly in the source directory. Instead, make a copy of all relevant sources in the git repository (everything except .git and files that are matched by gitignore) right before working with the source dir. Then use that copy instead. This avoids the problem that ./configure refuses to run if it has already been executed in the source dir. (It aborts and asks the user to run "make distclean" first, which is especially annoying if it has to be done in multiple source dirs before being able to build successfully.) Copying the sources is very fast due to generating a list of files that need to be copied first, and due to using rsync which skips the copy if the file size and timestamp already match. On my machine the copying is not noticable except for the additional prints: updating src_copy: /home/user/.cache/osmo-ttcn3-testenv/host/make2/src_copy/osmo-mgw/ updating version: 1.13.1.38-78ee9 Change-Id: I18ac50e3441df81e1fe7d8d5321df7e80ab9c650 --- M .gitignore M gen_makefile.py A src/_update_src_copy.sh 3 files changed, 161 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/04/39404/1 diff --git a/.gitignore b/.gitignore index 770ca29..0241046 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ !src/gits !src/grd !src/osmo-add-gerrit-hooks.sh +!src/_update_src_copy.sh !src/README net/* !net/templates* diff --git a/gen_makefile.py b/gen_makefile.py index e1baa5b..d4d175f 100755 --- a/gen_makefile.py +++ b/gen_makefile.py @@ -122,6 +122,9 @@ parser.add_argument('-i', '--install-prefix', default='/usr/local', help='''install there instead of /usr/local''') +parser.add_argument('-A', '--autoreconf-in-src-copy', action='store_true', + help="run autoreconf in a copy of the source dir, avoids 'run make distclean' errors") + args = parser.parse_args() class listdict(dict): @@ -175,12 +178,13 @@ return {} return dict(read_projects_deps(path)) -def gen_makefile_clone(proj, src, src_proj, url, push_url): +def gen_makefile_clone(proj, src, src_proj, url, push_url, update_src_copy_cmd): if proj == "osmocom-bb_layer23": return f''' .make.{proj}.clone: .make.osmocom-bb.clone @echo "\\n\\n\\n===== $@\\n" test -L {src_proj} || ln -s osmocom-bb/src/host/layer23 {src_proj} + {update_src_copy_cmd} touch $@ ''' @@ -189,6 +193,7 @@ .make.{proj}.clone: .make.osmocom-bb.clone @echo "\\n\\n\\n===== $@\\n" test -L {src_proj} || ln -s osmocom-bb/src/host/virt_phy {src_proj} + {update_src_copy_cmd} touch $@ ''' @@ -197,6 +202,7 @@ .make.{proj}.clone: .make.osmocom-bb.clone @echo "\\n\\n\\n===== $@\\n" test -L {src_proj} || ln -s osmocom-bb/src/host/trxcon {src_proj} + {update_src_copy_cmd} touch $@ ''' @@ -205,6 +211,7 @@ .make.{proj}.clone: .make.simtrace2.clone @echo "\\n\\n\\n===== $@\\n" test -L {src_proj} || ln -s simtrace2/host {src_proj} + {update_src_copy_cmd} touch $@ ''' @@ -240,17 +247,20 @@ ( {cmd_clone} && {cmd_set_push_url} ); \\ fi + {update_src_copy_cmd} sync touch $@ ''' -def gen_makefile_autoconf(proj, src_proj, distclean_cond): +def gen_makefile_autoconf(proj, src_proj, distclean_cond, update_src_copy_cmd): buildsystem = projects_buildsystems.get(proj, "autotools") + if buildsystem == "autotools": return f''' .make.{proj}.autoconf: .make.{proj}.clone {src_proj}/configure.ac if {distclean_cond}; then $(MAKE) {proj}-distclean; fi @echo "\\n\\n\\n===== $@\\n" + {update_src_copy_cmd} -rm -f {src_proj}/.version cd {src_proj}; autoreconf -fi sync @@ -263,13 +273,15 @@ def gen_makefile_configure(proj, deps_installed, distclean_cond, build_proj, - cflags, docker_cmd, build_to_src, configure_opts): + cflags, docker_cmd, build_to_src, configure_opts, + update_src_copy_cmd): buildsystem = projects_buildsystems.get(proj, "autotools") if buildsystem == "autotools": return f''' .make.{proj}.configure: .make.{proj}.autoconf {deps_installed} $({proj}_configure_files) if {distclean_cond}; then $(MAKE) {proj}-distclean .make.{proj}.autoconf; fi @echo "\\n\\n\\n===== $@\\n" + {update_src_copy_cmd} -chmod -R ug+w {build_proj} -rm -rf {build_proj} mkdir -p {build_proj} @@ -297,7 +309,7 @@ assert False, f"unknown buildsystem: {buildsystem}" def gen_makefile_build(proj, distclean_cond, build_proj, docker_cmd, jobs, - check, src_proj): + check, src_proj, update_src_copy_cmd): buildsystem = projects_buildsystems.get(proj, "autotools") if buildsystem == "autotools": @@ -305,6 +317,7 @@ .make.{proj}.build: .make.{proj}.configure $({proj}_files) if {distclean_cond}; then $(MAKE) {proj}-distclean .make.{proj}.configure; fi @echo "\\n\\n\\n===== $@\\n" + {update_src_copy_cmd} {docker_cmd}$(MAKE) -C {build_proj} -j {jobs} {check} sync touch $@ @@ -396,17 +409,46 @@ $(MAKE) -C {src_proj} distclean ''' +def is_src_copy_needed(proj): + if not args.autoreconf_in_src_copy: + return False + + # The rsync workaround to not write to the source dir during "autoreconf -fi" + # is only needed for autotools based projects + buildsystem = projects_buildsystems.get(proj, "autotools") + if buildsystem != "autotools": + return False + + return True + +def gen_update_src_copy_cmd(proj, src_dir, make_dir): + if not is_src_copy_needed(proj): + return "" + ret = "@sh -e " + ret += os.path.join(os.path.relpath(args.src_dir, make_dir), "_update_src_copy.sh") + ret += f" {shlex.quote(src_dir)}" + ret += f" {shlex.quote(proj)}" + ret += " $(TIME_START)" + return ret + +def gen_src_proj_copy(src_proj, make_dir, proj): + if not is_src_copy_needed(proj): + return src_proj + return os.path.join(make_dir, "src_copy", proj) + def gen_make(proj, deps, configure_opts, jobs, make_dir, src_dir, build_dir, url, push_url, sudo_make_install, no_ldconfig, ldconfig_without_sudo, make_check): src_proj = os.path.join(src_dir, proj) if proj == 'openbsc': src_proj = os.path.join(src_proj, 'openbsc') - build_proj = os.path.join(build_dir, proj) - build_to_src = os.path.relpath(src_proj, build_proj) - build_proj = os.path.relpath(build_proj, make_dir) - src = os.path.relpath(src_dir, make_dir) src_proj = os.path.relpath(src_proj, make_dir) + src_proj_copy = gen_src_proj_copy(src_proj, make_dir, proj) + + build_proj = os.path.join(build_dir, proj) + build_to_src = os.path.relpath(src_proj_copy, build_proj) + build_proj = os.path.relpath(build_proj, make_dir) + push_url = push_url or url if configure_opts: @@ -423,6 +465,7 @@ no_ldconfig = '#' if no_ldconfig else '' sudo_ldconfig = '' if ldconfig_without_sudo else 'sudo ' sudo_make_install = 'sudo ' if sudo_make_install else '' + update_src_copy_cmd = gen_update_src_copy_cmd(proj, src_dir, make_dir) return f''' ### {proj} ### @@ -443,9 +486,17 @@ \\) \\ -and -not -name "config.h" 2>/dev/null) -{gen_makefile_clone(proj, src, src_proj, url, push_url)} +{gen_makefile_clone(proj, + src, + src_proj, + url, + push_url, + update_src_copy_cmd)} -{gen_makefile_autoconf(proj, src_proj, distclean_cond)} +{gen_makefile_autoconf(proj, + src_proj_copy, + distclean_cond, + update_src_copy_cmd)} {gen_makefile_configure(proj, deps_installed, @@ -454,7 +505,8 @@ cflags, docker_cmd, build_to_src, - configure_opts_str)} + configure_opts_str, + update_src_copy_cmd)} {gen_makefile_build(proj, distclean_cond, @@ -462,7 +514,8 @@ docker_cmd, jobs, check, - src_proj)} + src_proj_copy, + update_src_copy_cmd)} {gen_makefile_install(proj, docker_cmd, @@ -606,8 +659,19 @@ content += " --build-debug \\\n" if args.auto_distclean: content += " --auto-distclean \\\n" +if args.autoreconf_in_src_copy: + content += " --autoreconf-in-src-copy \\\n" content += " $(NULL)\n" +if args.autoreconf_in_src_copy: + content += """ + +# --autoreconf-in-src-copy: get current time to avoid running rsync more than +# once within this Makefile per project +TIME_START := $(shell date +%s%N) + +""" + # convenience target: clone all repositories first content += 'clone: \\\n\t' + ' \\\n\t'.join([ '.make.%s.clone' % p for p, d in projects_deps ]) + '\n\n' diff --git a/src/_update_src_copy.sh b/src/_update_src_copy.sh new file mode 100644 index 0000000..d80b5fa --- /dev/null +++ b/src/_update_src_copy.sh @@ -0,0 +1,84 @@ +#!/bin/sh -e +# Update the src_copy dir with all relevant files from the original git +# repository (+ submodules). Used by gen_makefile.py --autoreconf-in-src-copy. + +MAKE_DIR="$PWD" +SRC_DIR="$1" +PROJ="$2" +TIME_START="$3" +MARKER="$MAKE_DIR/.make.$PROJ.src_copy" + +# Don't run more than once per "make" call +if [ "$(cat "$MARKER" 2>/dev/null)" = "$TIME_START" ]; then + exit 0 +fi + +DEST_DIR_PROJ="$MAKE_DIR/src_copy/$PROJ" +COPY_LIST="$(mktemp --suffix=-osmo-dev-rsync-copylist)" + +update_git_dir() { + local src="$1" + local dest="$DEST_DIR_PROJ/$(echo "$src" | cut -c 3-)" # cut: remove './' + + echo "updating src_copy: $dest" + + # Get list of files (everything that is not in gitignore) + git \ + -C "$src" \ + ls-files \ + --others \ + --cached \ + --exclude-standard \ + > "$COPY_LIST" + + mkdir -p "$dest" + + # Copy files that changed + rsync \ + --archive \ + --files-from="$COPY_LIST" \ + "$src" \ + "$dest" +} + +# The "git-version-gen" script only works correctly when running inside a git +# repository. Run it in the original git repo and copy its output to +# ".tarball-version", so when configure.ac runs it again the version gets read +# from there. +run_git_version_gen() { + if ! [ -e "$src/git-version-gen" ]; then + return + fi + + local version_file="$DEST_DIR_PROJ/$src/.tarball-version" + rm -f "$version_file" + + # git-version-gen does not run without the tarball-version argument + version_new="$(cd "$src" && ./git-version-gen "$version_file")" + + echo "updating version: $version_new" + echo "$version_new" >"$version_file" +} + +update_git_dirs_all() { + local git_dirs="$(find . -name '.git')" + + if [ -z "$git_dirs" ]; then + echo "_update_read_only_src_copy: find failed" + exit 1 + fi + + for git_dir in $git_dirs; do + local src="$(dirname "$git_dir")" + update_git_dir "$src" + run_git_version_gen "$src" + done +} + +cd "$SRC_DIR/$PROJ" +update_git_dirs_all +rm "$COPY_LIST" +echo "$TIME_START" >"$MARKER" + +# Output an empty line when done to make the Makefile output more readable +echo -- To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/39404?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-Change-Id: I18ac50e3441df81e1fe7d8d5321df7e80ab9c650 Gerrit-Change-Number: 39404 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-dev[master]: gen_makefile: modernize gen_make
by osmith 22 Jan '25

22 Jan '25
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-dev/+/39403?usp=email ) Change subject: gen_makefile: modernize gen_make ...................................................................... gen_makefile: modernize gen_make Use an f-string instead of .format() to make it more maintainable. Change-Id: I03350986c07226889b618869ec74a95be8712e3e --- M gen_makefile.py 1 file changed, 44 insertions(+), 41 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/03/39403/1 diff --git a/gen_makefile.py b/gen_makefile.py index 4a4748c..e1baa5b 100755 --- a/gen_makefile.py +++ b/gen_makefile.py @@ -424,62 +424,65 @@ sudo_ldconfig = '' if ldconfig_without_sudo else 'sudo ' sudo_make_install = 'sudo ' if sudo_make_install else '' - return r''' + return f''' ### {proj} ### -{proj}_configure_files := $(shell find -L {src_proj} \ - -name "Makefile.am" \ - -or -name "*.in" \ - -and -not -name "Makefile.in" \ +{proj}_configure_files := $(shell find -L {src_proj} \\ + -name "Makefile.am" \\ + -or -name "*.in" \\ + -and -not -name "Makefile.in" \\ -and -not -name "config.h.in" 2>/dev/null) -{proj}_files := $(shell find -L {src_proj} \ - \( \ - -name "*.[hc]" \ - -or -name "*.py" \ - -or -name "*.cpp" \ - -or -name "*.tpl" \ - -or -name "*.map" \ - -or -name "*.erl" \ - \) \ +{proj}_files := $(shell find -L {src_proj} \\ + \\( \\ + -name "*.[hc]" \\ + -or -name "*.py" \\ + -or -name "*.cpp" \\ + -or -name "*.tpl" \\ + -or -name "*.map" \\ + -or -name "*.erl" \\ + \\) \\ -and -not -name "config.h" 2>/dev/null) -{clone_rule} +{gen_makefile_clone(proj, src, src_proj, url, push_url)} -{autoconf_rule} +{gen_makefile_autoconf(proj, src_proj, distclean_cond)} -{configure_rule} +{gen_makefile_configure(proj, + deps_installed, + distclean_cond, + build_proj, + cflags, + docker_cmd, + build_to_src, + configure_opts_str)} -{build_rule} +{gen_makefile_build(proj, + distclean_cond, + build_proj, + docker_cmd, + jobs, + check, + src_proj)} -{install_rule} +{gen_makefile_install(proj, + docker_cmd, + sudo_make_install, + build_proj, + no_ldconfig, + sudo_ldconfig)} -{reinstall_rule} +{gen_makefile_reinstall(proj, + deps_reinstall, + sudo_make_install, + build_proj)} -{clean_rule} +{gen_makefile_clean(proj, build_proj)} -{distclean_rule} +{gen_makefile_distclean(proj, src_proj)} .PHONY: {proj} {proj}: .make.{proj}.install - -'''.format( - proj=proj, - src_proj=src_proj, - clone_rule=gen_makefile_clone(proj, src, src_proj, url, push_url), - autoconf_rule=gen_makefile_autoconf(proj, src_proj, distclean_cond), - configure_rule=gen_makefile_configure(proj, deps_installed, distclean_cond, - build_proj, cflags, docker_cmd, - build_to_src, configure_opts_str), - build_rule=gen_makefile_build(proj, distclean_cond, build_proj, docker_cmd, - jobs, check, src_proj), - install_rule=gen_makefile_install(proj, docker_cmd, sudo_make_install, - build_proj, no_ldconfig, sudo_ldconfig), - reinstall_rule=gen_makefile_reinstall(proj, deps_reinstall, - sudo_make_install, build_proj), - clean_rule=gen_makefile_clean(proj, build_proj), - distclean_rule=gen_makefile_distclean(proj, src_proj), - ) - +''' projects_deps = read_projects_deps(all_deps_file) projects_urls = read_projects_dict(all_urls_file) -- To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/39403?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-Change-Id: I03350986c07226889b618869ec74a95be8712e3e Gerrit-Change-Number: 39403 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de>
1 0
0 0
[M] Change in libosmo-sigtran[master]: Pass xua_msg down to xua_as_transmit_msg
by pespin 22 Jan '25

22 Jan '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39398?usp=email ) Change subject: Pass xua_msg down to xua_as_transmit_msg ...................................................................... Pass xua_msg down to xua_as_transmit_msg This finally allows having access to msg values such as OPC and SLS at the point in code where decision is taken to route the message to one ASP inside the AS. This will be needed to properly implemented ASP loadsharing within an AS. Change-Id: I70e5d33c7537dc0b72b5abced876e69018cc0829 --- M src/ipa.c M src/m3ua.c M src/sua.c M src/xua_as_fsm.c M src/xua_as_fsm.h M src/xua_internal.h M src/xua_msg.h 7 files changed, 60 insertions(+), 51 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/98/39398/1 diff --git a/src/ipa.c b/src/ipa.c index ac0cf3a..27b752d 100644 --- a/src/ipa.c +++ b/src/ipa.c @@ -52,7 +52,7 @@ #include "ss7_internal.h" #include "xua_asp_fsm.h" -static struct msgb *ipa_to_msg(struct xua_msg *xua) +struct msgb *ipa_to_msg(struct xua_msg *xua) { struct xua_msg_part *data_ie; struct m3ua_data_hdr *data_hdr; @@ -100,17 +100,9 @@ */ int ipa_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua) { - struct msgb *msg; OSMO_ASSERT(as->cfg.proto == OSMO_SS7_ASP_PROT_IPA); - msg = ipa_to_msg(xua); - xua_msg_free(xua); - if (!msg) { - LOGPAS(as, DLSS7, LOGL_ERROR, "Error encoding IPA Msg\n"); - return -1; - } - - return xua_as_transmit_msg(as, msg); + return xua_as_transmit_msg(as, xua); } static int ipa_rx_msg_ccm(struct osmo_ss7_asp *asp, struct msgb *msg) diff --git a/src/m3ua.c b/src/m3ua.c index 69910fb..d0cf604 100644 --- a/src/m3ua.c +++ b/src/m3ua.c @@ -473,7 +473,7 @@ ***********************************************************************/ /* Convert M3UA from xua_msg to msgb and set PPID/stream */ -static struct msgb *m3ua_to_msg(struct xua_msg *xua) +struct msgb *m3ua_to_msg(struct xua_msg *xua) { struct msgb *msg = xua_to_msg(M3UA_VERSION, xua); @@ -520,7 +520,6 @@ */ int m3ua_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua) { - struct msgb *msg; int rc; OSMO_ASSERT(as->cfg.proto == OSMO_SS7_ASP_PROT_M3UA); @@ -529,18 +528,11 @@ if (as->cfg.routing_key.context) xua_msg_add_u32(xua, M3UA_IEI_ROUTE_CTX, as->cfg.routing_key.context); - msg = m3ua_to_msg(xua); - xua_msg_free(xua); - if (!msg) { - LOGPAS(as, DLM3UA, LOGL_ERROR, "Error encoding M3UA Msg\n"); - return -1; - } - /* send the msg to the AS for transmission. The AS FSM might * (depending on its state) enqueue it before transmission */ - rc = osmo_fsm_inst_dispatch(as->fi, XUA_AS_E_TRANSFER_REQ, msg); + rc = osmo_fsm_inst_dispatch(as->fi, XUA_AS_E_TRANSFER_REQ, xua); if (rc < 0) - msgb_free(msg); + xua_msg_free(xua); return rc; } diff --git a/src/sua.c b/src/sua.c index 79e8567..d6e52e9 100644 --- a/src/sua.c +++ b/src/sua.c @@ -310,7 +310,6 @@ * \return 0 on success; negative on error */ int sua_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua) { - struct msgb *msg; int rc; OSMO_ASSERT(as->cfg.proto == OSMO_SS7_ASP_PROT_SUA); @@ -319,18 +318,11 @@ if (as->cfg.routing_key.context) xua_msg_add_u32(xua, SUA_IEI_ROUTE_CTX, as->cfg.routing_key.context); - msg = sua_to_msg(xua); - xua_msg_free(xua); - if (!msg) { - LOGPAS(as, DLSUA, LOGL_ERROR, "Error encoding SUA Msg\n"); - return -1; - } - /* send the msg to the AS for transmission. The AS FSM might * (depending on its state) enqueue it before transmission */ - rc = osmo_fsm_inst_dispatch(as->fi, XUA_AS_E_TRANSFER_REQ, msg); + rc = osmo_fsm_inst_dispatch(as->fi, XUA_AS_E_TRANSFER_REQ, xua); if (rc < 0) - msgb_free(msg); + xua_msg_free(xua); return rc; } diff --git a/src/xua_as_fsm.c b/src/xua_as_fsm.c index 6517f73..5c2c5e0 100644 --- a/src/xua_as_fsm.c +++ b/src/xua_as_fsm.c @@ -99,13 +99,29 @@ return -1; } -int xua_as_transmit_msg_broadcast(struct osmo_ss7_as *as, struct msgb *msg) +static struct msgb *xua_as_encode_msg(const struct osmo_ss7_as *as, struct xua_msg *xua) +{ + switch (as->cfg.proto) { + case OSMO_SS7_ASP_PROT_M3UA: + return m3ua_to_msg(xua); + case OSMO_SS7_ASP_PROT_IPA: + return ipa_to_msg(xua); + default: + OSMO_ASSERT(0); + } +} + +int xua_as_transmit_msg_broadcast(struct osmo_ss7_as *as, struct xua_msg *xua) { struct osmo_ss7_asp *asp; unsigned int i; + struct msgb *msg; struct msgb *msg_cpy; bool sent = false; + msg = xua_as_encode_msg(as, xua); + OSMO_ASSERT(msg); + for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) { asp = as->cfg.asps[i]; if (!asp || !osmo_ss7_asp_active(asp)) @@ -116,35 +132,41 @@ } msgb_free(msg); + xua_msg_free(xua); return sent ? 0 : -1; } /* actually transmit a message through this AS */ -int xua_as_transmit_msg(struct osmo_ss7_as *as, struct msgb *msg) +int xua_as_transmit_msg(struct osmo_ss7_as *as, struct xua_msg *xua) { struct osmo_ss7_asp *asp = NULL; + struct msgb *msg; switch (as->cfg.mode) { case OSMO_SS7_AS_TMOD_OVERRIDE: case OSMO_SS7_AS_TMOD_LOADSHARE: /* TODO: OSMO_SS7_AS_TMOD_LOADSHARE: actually use the SLS value - * to ensure same SLS goes through same ASP. Not strictly - * required by M3UA RFC, but would fit the overall principle. */ + * in xua->mtp.sls to ensure same SLS goes through same ASP. Not + * strictly required by M3UA RFC, but would fit the overall + * principle. */ case OSMO_SS7_AS_TMOD_ROUNDROBIN: asp = osmo_ss7_as_select_asp(as); break; case OSMO_SS7_AS_TMOD_BCAST: - return xua_as_transmit_msg_broadcast(as, msg); + return xua_as_transmit_msg_broadcast(as, xua); case _NUM_OSMO_SS7_ASP_TMOD: OSMO_ASSERT(false); } if (!asp) { LOGPFSM(as->fi, "No ASP in AS, dropping message\n"); - msgb_free(msg); + xua_msg_free(xua); return -1; } + msg = xua_as_encode_msg(as, xua); + OSMO_ASSERT(msg); + xua_msg_free(xua); return osmo_ss7_asp_send(asp, msg); } @@ -170,7 +192,7 @@ struct osmo_ss7_as *as; struct { struct osmo_timer_list t_r; - struct llist_head queued_msgs; + struct llist_head queued_xua_msgs; } recovery; bool ipa_route_created; }; @@ -424,7 +446,7 @@ { struct xua_as_fsm_priv *xafp = (struct xua_as_fsm_priv *) fi->priv; struct osmo_ss7_asp *asp; - struct msgb *msg; + struct xua_msg *xua; switch (event) { case XUA_ASPAS_ASP_DOWN_IND: @@ -449,8 +471,8 @@ break; case XUA_AS_E_TRANSFER_REQ: /* message for transmission */ - msg = data; - xua_as_transmit_msg(xafp->as, msg); + xua = data; + xua_as_transmit_msg(xafp->as, xua); break; } } @@ -458,7 +480,7 @@ static void xua_as_fsm_pending(struct osmo_fsm_inst *fi, uint32_t event, void *data) { struct xua_as_fsm_priv *xafp = (struct xua_as_fsm_priv *) fi->priv; - struct msgb *msg; + struct xua_msg *xua; switch (event) { case XUA_ASPAS_ASP_ACTIVE_IND: @@ -466,8 +488,12 @@ osmo_timer_del(&xafp->recovery.t_r); osmo_fsm_inst_state_chg(fi, XUA_AS_S_ACTIVE, 0, 0); /* push out any pending queued messages */ - while ((msg = msgb_dequeue(&xafp->recovery.queued_msgs))) - xua_as_transmit_msg(xafp->as, msg); + while (!llist_empty(&xafp->recovery.queued_xua_msgs)) { + struct xua_msg *xua; + xua = llist_first_entry(&xafp->recovery.queued_xua_msgs, struct xua_msg, entry); + llist_del(&xua->entry); + xua_as_transmit_msg(xafp->as, xua); + } break; case XUA_ASPAS_ASP_INACTIVE_IND: /* ignore */ @@ -477,8 +503,12 @@ break; case XUA_AS_E_RECOVERY_EXPD: LOGPFSM(fi, "T(r) expired; dropping queued messages\n"); - while ((msg = msgb_dequeue(&xafp->recovery.queued_msgs))) - talloc_free(msg); + while (!llist_empty(&xafp->recovery.queued_xua_msgs)) { + struct xua_msg *xua; + xua = llist_first_entry(&xafp->recovery.queued_xua_msgs, struct xua_msg, entry); + llist_del(&xua->entry); + xua_msg_free(xua); + } if (check_any_other_asp_not_down(xafp->as, NULL)) osmo_fsm_inst_state_chg(fi, XUA_AS_S_INACTIVE, 0, 0); else @@ -486,8 +516,8 @@ break; case XUA_AS_E_TRANSFER_REQ: /* enqueue the to-be-transferred message */ - msg = data; - msgb_enqueue(&xafp->recovery.queued_msgs, msg); + xua = data; + llist_add_tail(&xua->entry, &xafp->recovery.queued_xua_msgs); break; } } @@ -575,7 +605,7 @@ xafp->as = as; xafp->recovery.t_r.cb = t_r_callback; xafp->recovery.t_r.data = fi; - INIT_LLIST_HEAD(&xafp->recovery.queued_msgs); + INIT_LLIST_HEAD(&xafp->recovery.queued_xua_msgs); fi->priv = xafp; diff --git a/src/xua_as_fsm.h b/src/xua_as_fsm.h index 0e71350..6d7d762 100644 --- a/src/xua_as_fsm.h +++ b/src/xua_as_fsm.h @@ -14,7 +14,7 @@ XUA_ASPAS_ASP_DOWN_IND, XUA_ASPAS_ASP_ACTIVE_IND, XUA_AS_E_RECOVERY_EXPD, - XUA_AS_E_TRANSFER_REQ, + XUA_AS_E_TRANSFER_REQ, /* param: struct xua_msg*, ownsership transferred. */ }; extern struct osmo_fsm xua_as_fsm; diff --git a/src/xua_internal.h b/src/xua_internal.h index 4f6e931..926c511 100644 --- a/src/xua_internal.h +++ b/src/xua_internal.h @@ -33,6 +33,7 @@ struct osmo_mtp_prim *m3ua_to_xfer_ind(struct xua_msg *xua); int m3ua_hmdc_rx_from_l2(struct osmo_ss7_instance *inst, struct xua_msg *xua); +struct msgb *m3ua_to_msg(struct xua_msg *xua); int m3ua_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua); void m3ua_tx_snm_available(struct osmo_ss7_asp *asp, const uint32_t *rctx, unsigned int num_rctx, const uint32_t *aff_pc, unsigned int num_aff_pc, @@ -113,11 +114,12 @@ #define PC_STR "Point Code\n" #define INST_STR "An instance of the SS7 stack\n" -int xua_as_transmit_msg(struct osmo_ss7_as *as, struct msgb *msg); +int xua_as_transmit_msg(struct osmo_ss7_as *as, struct xua_msg *xua); int xua_find_as_for_asp(struct osmo_ss7_as **as, const struct osmo_ss7_asp *asp, const struct xua_msg_part *rctx_ie); +struct msgb *ipa_to_msg(struct xua_msg *xua); int ipa_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua); int ipa_rx_msg(struct osmo_ss7_asp *asp, struct msgb *msg, uint8_t sls); struct osmo_ss7_as *ipa_find_as_for_asp(struct osmo_ss7_asp *asp); diff --git a/src/xua_msg.h b/src/xua_msg.h index 5f877ed..79af86f 100644 --- a/src/xua_msg.h +++ b/src/xua_msg.h @@ -29,6 +29,7 @@ struct osmo_sccp_gt; struct xua_msg { + struct llist_head entry; /* Allows queueing a xua_msg into a llist */ struct xua_common_hdr hdr; struct osmo_mtp_transfer_param mtp; -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/39398?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I70e5d33c7537dc0b72b5abced876e69018cc0829 Gerrit-Change-Number: 39398 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in libosmo-sigtran[master]: Pass ownership of Rx xua_msg up the stack [2/2]
by pespin 22 Jan '25

22 Jan '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39397?usp=email ) Change subject: Pass ownership of Rx xua_msg up the stack [2/2] ...................................................................... Pass ownership of Rx xua_msg up the stack [2/2] This is the second step patch where we also pass ownership on Rx path so that forwarded xua_msgs can be passed back to the Tx path without freeing them. For SUA there's no change needed and we keep freeing the rx xua_msg right at the end of sua_rx_msg() since there's no actual path forwarding a xua_msg object back into Tx path, it always goes through upper layers using newly allocated primitives. Change-Id: Icf3b4dda550637f722a9fe56d0313f49c8a2964e --- M src/ipa.c M src/m3ua.c M src/xua_rkm.c 3 files changed, 46 insertions(+), 23 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/97/39397/1 diff --git a/src/ipa.c b/src/ipa.c index 944fbce..ac0cf3a 100644 --- a/src/ipa.c +++ b/src/ipa.c @@ -300,9 +300,9 @@ /* Update xua->mtp with values from data_hdr */ m3ua_dh_to_xfer_param(&xua->mtp, &data_hdr); - /* Pass on as if we had received it from an M3UA ASP */ + /* Pass on as if we had received it from an M3UA ASP. + * xua ownsership is passed here: */ rc = m3ua_hmdc_rx_from_l2(asp->inst, xua); - xua_msg_free(xua); return rc; } diff --git a/src/m3ua.c b/src/m3ua.c index dbdd4e2..69910fb 100644 --- a/src/m3ua.c +++ b/src/m3ua.c @@ -566,6 +566,7 @@ return data_hdr; } +/* This function takes ownership of xua msg passed to it. */ static int m3ua_rx_xfer(struct osmo_ss7_asp *asp, struct xua_msg *xua) { struct xua_msg_part *na_ie = xua_msg_find_tag(xua, M3UA_IEI_NET_APPEAR); @@ -581,7 +582,8 @@ "%s(): unsupported message type: %s\n", __func__, get_value_string(m3ua_xfer_msgt_names, xua->hdr.msg_type)); - return M3UA_ERR_UNSUPP_MSG_TYPE; + rc = M3UA_ERR_UNSUPP_MSG_TYPE; + goto ret_free; } /* Reject unsupported Network Appearance IE. */ @@ -592,13 +594,15 @@ "Unsupported 'Network Appearance' IE '0x%08x' in message type '%s', sending 'Error'.\n", na, get_value_string(m3ua_xfer_msgt_names, xua->hdr.msg_type)); if (na_ie->len != 4) - return M3UA_ERR_PARAM_FIELD_ERR; - return M3UA_ERR_INVAL_NET_APPEAR; + rc = M3UA_ERR_PARAM_FIELD_ERR; + else + rc = M3UA_ERR_INVAL_NET_APPEAR; + goto ret_free; } rc = xua_find_as_for_asp(&as, asp, rctx_ie); if (rc) - return rc; + goto ret_free; rate_ctr_inc2(as->ctrg, SS7_AS_CTR_RX_MSU_TOTAL); @@ -620,8 +624,12 @@ xua_msg_free_tag(xua, M3UA_IEI_ROUTE_CTX); } + /* xua ownsership is passed here: */ return m3ua_hmdc_rx_from_l2(asp->inst, xua); - /* xua will be freed by caller m3ua_rx_msg() */ + +ret_free: + xua_msg_free(xua); + return rc; } static int m3ua_rx_mgmt_err(struct osmo_ss7_asp *asp, struct xua_msg *xua) @@ -681,16 +689,24 @@ return 0; } +/* This function takes ownership of xua msg passed to it. */ static int m3ua_rx_mgmt(struct osmo_ss7_asp *asp, struct xua_msg *xua) { + int rc; + switch (xua->hdr.msg_type) { case M3UA_MGMT_ERR: - return m3ua_rx_mgmt_err(asp, xua); + rc = m3ua_rx_mgmt_err(asp, xua); + break; case M3UA_MGMT_NTFY: - return m3ua_rx_mgmt_ntfy(asp, xua); + rc = m3ua_rx_mgmt_ntfy(asp, xua); + break; default: - return M3UA_ERR_UNSUPP_MSG_TYPE; + rc = M3UA_ERR_UNSUPP_MSG_TYPE; } + + xua_msg_free(xua); + return rc; } /* map from M3UA ASPSM/ASPTM to xua_asp_fsm event */ @@ -707,23 +723,26 @@ { M3UA_MSGC_ASPTM, M3UA_ASPTM_INACTIVE_ACK, XUA_ASP_E_ASPTM_ASPIA_ACK }, }; - +/* This function takes ownership of xua msg passed to it. */ static int m3ua_rx_asp(struct osmo_ss7_asp *asp, struct xua_msg *xua) { int event; + int rc = 0; /* map from the M3UA message class and message type to the XUA * ASP FSM event number */ event = xua_msg_event_map(xua, m3ua_aspxm_map, ARRAY_SIZE(m3ua_aspxm_map)); - if (event < 0) - return M3UA_ERR_UNSUPP_MSG_TYPE; + if (event < 0) { + rc = M3UA_ERR_UNSUPP_MSG_TYPE; + goto ret_free; + } /* deliver that event to the ASP FSM */ - if (osmo_fsm_inst_dispatch(asp->fi, event, xua) < 0) - return M3UA_ERR_UNEXPECTED_MSG; - - return 0; + rc = osmo_fsm_inst_dispatch(asp->fi, event, xua); +ret_free: + xua_msg_free(xua); + return rc; } static int m3ua_rx_snm(struct osmo_ss7_asp *asp, struct xua_msg *xua); @@ -804,8 +823,6 @@ if (err) m3ua_tx_xua_asp(asp, err); - xua_msg_free(xua); - return rc; } @@ -955,7 +972,8 @@ m3ua_tx_xua_asp(asp, xua); } -/* received SNM message on ASP side */ +/* received SNM message on ASP side + * This function takes ownership of xua msg passed to it. */ static int m3ua_rx_snm_asp(struct osmo_ss7_asp *asp, struct xua_msg *xua) { struct osmo_ss7_as *as = NULL; @@ -964,7 +982,7 @@ rc = xua_find_as_for_asp(&as, asp, rctx_ie); if (rc) - return rc; + goto ret_free; /* report those up the stack so both other ASPs and local SCCP users can be notified */ switch (xua->hdr.msg_type) { @@ -1001,7 +1019,9 @@ return M3UA_ERR_UNSUPP_MSG_TYPE; } - return 0; +ret_free: + xua_msg_free(xua); + return rc; } /* received SNM message on SG side */ diff --git a/src/xua_rkm.c b/src/xua_rkm.c index 9a3918e..73461ec 100644 --- a/src/xua_rkm.c +++ b/src/xua_rkm.c @@ -532,7 +532,8 @@ return 0; } -/* process an incoming RKM message in xua format */ +/* process an incoming RKM message in xua format + * This function takes ownership of xua msg passed to it. */ int m3ua_rx_rkm(struct osmo_ss7_asp *asp, struct xua_msg *xua) { int rc; @@ -562,6 +563,8 @@ rc = -1; break; } + + xua_msg_free(xua); return rc; } -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/39397?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: Icf3b4dda550637f722a9fe56d0313f49c8a2964e Gerrit-Change-Number: 39397 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in libosmo-sigtran[master]: Pass ownership of Tx xua_msg down the stack [1/2]
by pespin 22 Jan '25

22 Jan '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39396?usp=email ) Change subject: Pass ownership of Tx xua_msg down the stack [1/2] ...................................................................... Pass ownership of Tx xua_msg down the stack [1/2] This is a first step towards getting MTP OPC & SLS fields down the stack so that they can be used to implement loadsharing at ASP level. So far, we always encode the xua_msg (which holds the OPC and SLS info into xua_msg->mtp) into a msgb before passing it to as->fi through event XUA_AS_E_TRANSFER_REQ, which in turn calls xua_as_transmit_msg(as, msg). This patch is part 1 of 2 patches, which only modifies mostly the Tx path, but still requires modifications on Rx path (done in patch 2/2) to properly handle the forwarding path from Rx to Tx without double freeing. It is submitted in 2 parts to ease code reviewing. Future patches will modify that code to pass a xua_msg and only encode it into a msgb deeper into the stack after an ASP has been selected and msg needs to be transmitted. All previous calls to sua_tx_xua_asp() actually had a memory leak before this change, hence why no xua_msg_free() is removed from callers in this patch. Since now ownership is taken by sua_tx_xua_asp() which always frees the xua msg, the memleak is fixed. Change-Id: I49e718e624da08510a9c3d28bdb360c59f9a65d3 --- M src/ipa.c M src/m3ua.c M src/osmo_ss7_hmrt.c M src/sua.c 4 files changed, 49 insertions(+), 19 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/96/39396/1 diff --git a/src/ipa.c b/src/ipa.c index 6ca5b50..944fbce 100644 --- a/src/ipa.c +++ b/src/ipa.c @@ -94,13 +94,17 @@ /*! \brief Send a given xUA message via a given IPA "Application Server" * \param[in] as Application Server through which to send \a xua * \param[in] xua xUA message to be sent - * \return 0 on success; negative on error */ + * \return 0 on success; negative on error + * + * This function takes ownership of xua msg passed to it. + */ int ipa_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua) { struct msgb *msg; OSMO_ASSERT(as->cfg.proto == OSMO_SS7_ASP_PROT_IPA); msg = ipa_to_msg(xua); + xua_msg_free(xua); if (!msg) { LOGPAS(as, DLSS7, LOGL_ERROR, "Error encoding IPA Msg\n"); return -1; diff --git a/src/m3ua.c b/src/m3ua.c index 5f94674..dbdd4e2 100644 --- a/src/m3ua.c +++ b/src/m3ua.c @@ -493,23 +493,31 @@ return msg; } -/* transmit given xua_msg via given ASP */ +/* transmit given xua_msg via given ASP + * This function takes ownership of xua msg passed to it. + */ static int m3ua_tx_xua_asp(struct osmo_ss7_asp *asp, struct xua_msg *xua) { - struct msgb *msg = m3ua_to_msg(xua); + struct msgb *msg; OSMO_ASSERT(asp->cfg.proto == OSMO_SS7_ASP_PROT_M3UA); + msg = m3ua_to_msg(xua); + xua_msg_free(xua); if (!msg) return -1; + /* msg becomes owned by osmo_ss7_asp_send here: */ return osmo_ss7_asp_send(asp, msg); } /*! \brief Send a given xUA message via a given M3UA Application Server * \param[in] as Application Server through which to send \ref xua * \param[in] xua xUA message to be sent - * \return 0 on success; negative on error */ + * \return 0 on success; negative on error + * + * This function takes ownership of xua msg passed to it. + */ int m3ua_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua) { struct msgb *msg; @@ -522,6 +530,7 @@ xua_msg_add_u32(xua, M3UA_IEI_ROUTE_CTX, as->cfg.routing_key.context); msg = m3ua_to_msg(xua); + xua_msg_free(xua); if (!msg) { LOGPAS(as, DLM3UA, LOGL_ERROR, "Error encoding M3UA Msg\n"); return -1; @@ -792,10 +801,8 @@ err = m3ua_gen_error_msg(rc, msg); out: - if (err) { + if (err) m3ua_tx_xua_asp(asp, err); - xua_msg_free(err); - } xua_msg_free(xua); @@ -898,7 +905,6 @@ xua = m3ua_encode_duna(rctx, num_rctx, aff_pc, num_aff_pc, info_string); m3ua_tx_xua_asp(asp, xua); - xua_msg_free(xua); } /*! Transmit SSNM SCON message indicating congestion @@ -932,7 +938,6 @@ xua_msg_add_data(xua, M3UA_IEI_INFO_STRING, strlen(info_string)+1, (const uint8_t *) info_string); m3ua_tx_xua_asp(asp, xua); - xua_msg_free(xua); } /*! Transmit SSNM DUPU message indicating user unavailability. @@ -948,7 +953,6 @@ { struct xua_msg *xua = m3ua_encode_dupu(rctx, num_rctx, dpc, user, cause, info_str); m3ua_tx_xua_asp(asp, xua); - xua_msg_free(xua); } /* received SNM message on ASP side */ diff --git a/src/osmo_ss7_hmrt.c b/src/osmo_ss7_hmrt.c index 5fca2d8..5200bb9 100644 --- a/src/osmo_ss7_hmrt.c +++ b/src/osmo_ss7_hmrt.c @@ -86,24 +86,35 @@ return m3ua_xfer_from_data(&data_hdr, msgb_l2(msg), msgb_l2len(msg)); } -/* delivery given XUA message to given SS7 user */ +/* delivery given XUA message to given SS7 user + * Ownership of xua_msg passed is transferred to this function. + */ static int deliver_to_mtp_user(const struct osmo_ss7_user *osu, struct xua_msg *xua) { struct osmo_mtp_prim *prim; + int rc; /* Create MTP-TRANSFER.ind and feed to user */ prim = m3ua_to_xfer_ind(xua); - if (!prim) - return -1; + if (!prim) { + rc = -1; + goto ret_free; + } prim->u.transfer = xua->mtp; - return osu->prim_cb(&prim->oph, (void *) osu->priv); + rc = osu->prim_cb(&prim->oph, (void *) osu->priv); + +ret_free: + xua_msg_free(xua); + return rc; } /* HMDC -> HMDT: Message for distribution; Figure 25/Q.704 */ /* This means it is a message we received from remote/L2, and it is to - * be routed to a local user part */ + * be routed to a local user part. + * Ownership of xua_msg passed is transferred to this function. + */ static int hmdt_message_for_distribution(struct osmo_ss7_instance *inst, struct xua_msg *xua) { struct m3ua_data_hdr *mdh; @@ -120,6 +131,7 @@ default: LOGP(DLSS7, LOGL_ERROR, "Unknown M3UA XFER Message " "Type %u\n", xua->hdr.msg_type); + xua_msg_free(xua); return -1; } break; @@ -131,6 +143,7 @@ /* Discard Message */ LOGP(DLSS7, LOGL_ERROR, "Unknown M3UA Message Class %u\n", xua->hdr.msg_class); + xua_msg_free(xua); return -1; } @@ -142,6 +155,7 @@ LOGP(DLSS7, LOGL_NOTICE, "No MTP-User for SI %u\n", service_ind); /* Discard Message */ /* FIXME: User Part Unavailable HMDT -> HMRT */ + xua_msg_free(xua); return -1; } } @@ -207,7 +221,9 @@ /* HMDC->HMRT Msg For Routing; Figure 26/Q.704 */ /* local message was receive d from L4, SRM, SLM, STM or SLTC, or - * remote message received from L2 and HMDC determined msg for routing */ + * remote message received from L2 and HMDC determined msg for routing + * Ownership of xua_msg passed is transferred to this function. + */ static int hmrt_message_for_routing(struct osmo_ss7_instance *inst, struct xua_msg *xua) { @@ -237,6 +253,7 @@ if (osmo_ss7_as_down(as)) { LOGP(DLSS7, LOGL_ERROR, "Unable to route HMRT message: the AS %s is down\n", as->cfg.name); + xua_msg_free(xua); return -ENETDOWN; } @@ -272,12 +289,14 @@ /* Message Received for inaccesible SP HMRT ->RTPC */ /* Discard Message */ } + xua_msg_free(xua); return -1; } /* HMDC: Received Message L2 -> L3; Figure 24/Q.704 */ /* This means a message was received from L2 and we have to decide if it - * is for the local stack (HMDT) or for routng (HMRT) */ + * is for the local stack (HMDT) or for routng (HMRT) + * Ownership of xua_msg passed is transferred to this function. */ int m3ua_hmdc_rx_from_l2(struct osmo_ss7_instance *inst, struct xua_msg *xua) { uint32_t dpc = xua->mtp.dpc; @@ -314,7 +333,6 @@ * IPv4). So we call m3ua_hmdc_rx_from_l2() just like * the MTP-TRANSFER had been received from L2. */ rc = m3ua_hmdc_rx_from_l2(inst, xua); - xua_msg_free(xua); break; default: LOGP(DLSS7, LOGL_ERROR, "Ignoring unknown primitive %u:%u\n", diff --git a/src/sua.c b/src/sua.c index e81c471..79e8567 100644 --- a/src/sua.c +++ b/src/sua.c @@ -291,13 +291,16 @@ static int sua_tx_xua_asp(struct osmo_ss7_asp *asp, struct xua_msg *xua) { - struct msgb *msg = sua_to_msg(xua); + struct msgb *msg; OSMO_ASSERT(asp->cfg.proto == OSMO_SS7_ASP_PROT_SUA); + msg = sua_to_msg(xua); + xua_msg_free(xua); if (!msg) return -1; + /* msg becomes owned by osmo_ss7_asp_send here: */ return osmo_ss7_asp_send(asp, msg); } @@ -317,6 +320,7 @@ xua_msg_add_u32(xua, SUA_IEI_ROUTE_CTX, as->cfg.routing_key.context); msg = sua_to_msg(xua); + xua_msg_free(xua); if (!msg) { LOGPAS(as, DLSUA, LOGL_ERROR, "Error encoding SUA Msg\n"); return -1; -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/39396?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I49e718e624da08510a9c3d28bdb360c59f9a65d3 Gerrit-Change-Number: 39396 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • ...
  • 150
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.