Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Trying to recompile mpd5 to override the PPPOE_CONNECT_TIMEOUT

    Scheduled Pinned Locked Moved Development
    11 Posts 4 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      aelakkad
      last edited by

      I have a very slow ISP to respond to PADI packets (around 15 seconds) and the timeout is hardcoded into the freebsd port to 9 seconds.

      I researched and asked around and was told the way to do it would be rebuild the port (had no idea how to do that so research and asked again)

      What I reached was the pfsense machine itself won't compile so I had to build it on another machine and then install it on pfsense afterward.

      Here is the problem, I cloned the git, went into /net/mpd5/ and edited the Makefile to this, added "PPPOE_CONNECT_TIMEOUT= 30" towards the end:

      PORTNAME=       mpd
      DISTVERSION=    5.9
      PORTREVISION=   16
      CATEGORIES=     net
      MASTER_SITES=   SF/${PORTNAME}/Mpd5/Mpd-${PORTVERSION}
      PKGNAMESUFFIX=  5
      DIST_SUBDIR=    mpd5
      
      MAINTAINER=     eugen@FreeBSD.org
      COMMENT=        Multi-link PPP daemon based on netgraph(4)
      WWW=            https://sourceforge.net/projects/mpd/
      
      LICENSE=        BSD3CLAUSE
      
      USES=           cpe ssl
      
      CPE_VENDOR=     mpd_project
      
      OPTIONS_DEFINE= DOCS NG_IPACCT RADIUS
      OPTIONS_DEFAULT=        RADIUS
      NG_IPACCT_DESC= Use ng_ipacct kernel module from port
      RADIUS_DESC=    Enable RADIUS support
      HAS_CONFIGURE=  YES
      CONFIGURE_WRKSRC=       "${WRKSRC}/src"
      
      .include <bsd.port.options.mk>
      
      MAKE_ARGS+=     OSVERSION=${OSVERSION}
      
      .if ${PORT_OPTIONS:MNG_IPACCT}
      BUILD_DEPENDS+= ${LOCALBASE}/include/netgraph/ng_ipacct.h:net-mgmt/ng_ipacct
      .if exists(${KMODDIR}/ng_ipacct.ko)
      RUN_DEPENDS+=   ${KMODDIR}/ng_ipacct.ko:net-mgmt/ng_ipacct
      .else
      RUN_DEPENDS+=   /boot/modules/ng_ipacct.ko:net-mgmt/ng_ipacct
      .endif
      .else
      CONFIGURE_ENV+= USE_NG_IPACCT=no
      MAKE_ARGS+=     USE_NG_IPACCT=no
      .endif
      
      .if ${PORT_OPTIONS:MRADIUS}
      PLIST_FILES=    ${DATADIR}/dictionary.mpd
      
      post-install:
                      ${MKDIR} ${STAGEDIR}${DATADIR}
                      ${INSTALL_DATA} ${WRKSRC}/conf/dictionary.mpd ${STAGEDIR}${DATADIR}
      .else
      CONFIGURE_ENV+= USE_RADIUS=no
      MAKE_ARGS+=     USE_RADIUS=no
      .endif
      
      USE_RC_SUBR=    mpd5
      CONFSUF=        conf secret script
      DOCSDIR=        ${PREFIX}/share/doc/mpd5
      PORTDOCS=       README mpd*
      PLIST_FILES+=   ${CONFSUF:C|(.*)|"@sample etc/mpd5/mpd.\1.sample"|} \
                      sbin/mpd5
      
      .if !defined(WITHOUT_MAN)
      PLIST_FILES+=   man/man8/mpd5.8.gz
      PPPOE_CONNECT_TIMEOUT= 30
      .endif
      
      .include <bsd.port.mk>
      

      Then I ran "make clean" then "make package"

      Then went into the /works/pkg and found mpd5-5.9_16.pkg and then copied it over the pfsense machine, and then ran "pkg set -v 0 pfSense" and then "pkg delete mpd5" and then "pkg add --force mpd5-5.9_16.pkg" and it said installed and I rebooted it but still the timeout is at 9 seconds and it keeps retrying.

      Any help or advice on what to do here?

      bmeeksB 1 Reply Last reply Reply Quote 0
      • bmeeksB
        bmeeks @aelakkad
        last edited by bmeeks

        @aelakkad said in Trying to recompile mpd5 to override the PPPOE_CONNECT_TIMEOUT:

        Here is the problem, I cloned the git, went into /net/mpd5/ and edited the Makefile to this, added "PPPOE_CONNECT_TIMEOUT= 30" towards the end:

        That's not the correct procedure. You can't fix it by editing the Makefile. You will need to actually extract the full C source code file tree, modify the applicable C source code file, creat a diff patch file of the changes, and then add that new patch file to the files sub-directory in the port's tree. Then when you compile and link the new package it will contain the change you desire.

        You will need to know how to code in the C language to pull this off. I'm pretty sure it can't be done by adding one line to the Makefile.

        And "no", I'm sorry but I can't tell you which exact source file to edit. I just know the process of making changes to the source code of ports. It starts by downloading the C source code archive from the URL specified in the Makefile you have. You can also use tools on your ports builder machine to do this step.

        Edit: found one of your posts on the FreeBSD forum here: https://forums.freebsd.org/threads/override-mpd-pppoe-client-timeout.90413/. You need to fully follow the instructions there. From your writeup above, it appears you misunderstood the steps. For starters, you edited the wrong file.

        A 1 Reply Last reply Reply Quote 0
        • jimpJ jimp moved this topic from Problems Installing or Upgrading pfSense Software on
        • A
          aelakkad @bmeeks
          last edited by

          @bmeeks Yeah, I guess I got it wrong. They just don't appear to have the same file structure, so I am a little confused and don't know how to apply the same thing to the pfsense port of mpd5. Also, I found out (correct me if I'm wrong) pfsense doesn't include the make command, so if I get this working on another VM, I'll have a hard time getting it into pfsense afterwards, do I run make package and then add in pfsense? or I should copy it there? I've been trying to get this working for almost a month now and it's been very hard to find something that helps or could guide me through it and all for what I really think is something really simple (may my ISP burn in hell for the stupid slow infrastructure, they literally admitted they can't get it faster than 12-15 seconds) :/ I sure did learn some stuff along the way tho ๐Ÿ˜

          bmeeksB 1 Reply Last reply Reply Quote 0
          • bmeeksB
            bmeeks @aelakkad
            last edited by bmeeks

            @aelakkad said in Trying to recompile mpd5 to override the PPPOE_CONNECT_TIMEOUT:

            @bmeeks Yeah, I guess I got it wrong. They just don't appear to have the same file structure, so I am a little confused and don't know how to apply the same thing to the pfsense port of mpd5. Also, I found out (correct me if I'm wrong) pfsense doesn't include the make command, so if I get this working on another VM, I'll have a hard time getting it into pfsense afterwards, do I run make package and then add in pfsense? or I should copy it there? I've been trying to get this working for almost a month now and it's been very hard to find something that helps or could guide me through it and all for what I really think is something really simple (may my ISP burn in hell for the stupid slow infrastructure, they literally admitted they can't get it faster than 12-15 seconds) :/ I sure did learn some stuff along the way tho ๐Ÿ˜

            You can't do any of the fixes required on your pfSense box. It does not have a FreeBSD development environment installed (and you should never attempt to add one to it).

            You will need to create a completely separate FreeBSD development system . You can do this by creating a virtual machine on some other hardware host, or you can construct one on bare metal using a spare piece of hardware.

            It appears you have never compiled and linked code on FreeBSD. You have a lot to learn in order to pull this off. You absolutely cannot do this by editing a single file. It is a multi-step process involving lots of files and following a specific process. At the end you can produce either a single binary executable or a complete FreeBSD package. But whichever method you choose requires you to have a build environment whose FreeBSD kernel matches the version used by the pfSense machine you are targeting.

            You can start by reading this long thread from the forum: https://forum.netgate.com/topic/169749/pfsense-compile-requirements-for-3rd-party-software. The original poster in that thread needed to customize/patch the upnpd deamon in pfSense. You need to accomplish something similar with mpd5.

            But unless you have prior experience writing and compiling C source code into executable binary modules, this is not going to be an easy task for you. Your additional questions in the reply to my first post indicate you are not understanding some key concepts -- including how the Ports tree in FreeBSD works. It does not contain all the source code files. It contains only specific patches to the source code tree and then a Makefile that contains the URL where the code compilation and linking process can go to download and then unpack the entire souce code file tree for the package. Once the source code is unpacked into a working directory tree, any applicable patches are applied (those will be found in the files subdirectory of the port in the Ports tree), then the source code is compiled and linked into an executable binary. It can also be packged into a pkg compatible package file. At the end of the build process, you can copy either the single binary executable over to your pfSense firewall, or you can create a package and copy it over to the firewall and install it using the pkg utility along with the requisite command-line arguments.

            A 1 Reply Last reply Reply Quote 1
            • A
              aelakkad @bmeeks
              last edited by

              @bmeeks Thank you, I appreciate it. I will try to learn and try it out. Thanks again.

              1 Reply Last reply Reply Quote 0
              • stephenw10S
                stephenw10 Netgate Administrator
                last edited by

                Mmm, this is not an easy starter edit! ๐Ÿ˜‰

                Were you able to get any further?

                A 1 Reply Last reply Reply Quote 0
                • A
                  aelakkad @stephenw10
                  last edited by

                  @stephenw10 honestly no.. I went through it and it was pretty hard to get an overview to work with, have to really learn the details and try it out a lot. I'm thinking of going with a double NAT and adding the pfsense appliance as a DMZ to try and mitigate some of the issues that come with double NAT, I actually need to learn how to make it work correctly in a double NAT (in terms of port forwarding if needed and firewall rules). Do you think double NAT is pretty bad?

                  GertjanG 1 Reply Last reply Reply Quote 0
                  • stephenw10S
                    stephenw10 Netgate Administrator
                    last edited by

                    I'm behind triple NAT as I write this. ๐Ÿ˜‰

                    It's better not to be but most things will work fine with it. Port forwarding is more complex. UPnP will not work.

                    1 Reply Last reply Reply Quote 0
                    • GertjanG
                      Gertjan @aelakkad
                      last edited by Gertjan

                      @aelakkad

                      I saw your :

                      Thank you! I will try it out, appreciate it a lot!

                      and it can be done.
                      In the future, you'll be posting back here and saying "It wasn't worth it".

                      What you want is this :
                      You're in a plain : edit : like us all : as a passenger - , and its really annoying you that it takes the curves to sharply. You want to change that.
                      No issue at all.
                      Go for your pilot one engin, multiple engine exams.
                      Then take commercial plain lessons, and get that one done. Get 1000 hours of experience under the belt, and now you are ready : you are hired by some air company and you are flying that plain yourself, and you're approaching that corner.
                      Switch of the auto pilot.
                      Do the flying manually, as you want it to happen.
                      Done.

                      This scenario will also take you also four years or so, on the average.
                      An there is no rocket science involved here. Tens of thousands have done exactly done that - me included. [ ok, I admit : took me years ... using X-Plane 12, but now I can actually prepare, take off, cruise, and land a Boeing 738-800 without 'dying'. I've tested myself in a real 'official' Boeing flight simulator ]

                      I'd like to point out a shortcut.

                      This :

                      -#define PPPOE_CONNECT_TIMEOUT    9
                      +#define PPPOE_CONNECT_TIMEOUT    25
                      

                      means that there is a constant defined in the mpd5 binary that contains the value of "09" decimal, or probably 0x09 hex.
                      It could be stored in the executable file as .. 09 ... or .... 00 09 ... or 09 00... or 00 00 00 09 ... or 00 00 09 00 ... or 09 00 00 00 .. (8 bits, 16 bits, 32 bits maybe 64 bits ?)
                      So, "all" you need to do is : open the file in a hex editor (Notepad++ can do the job) and change that "9" value to "19".

                      The only thing you have to do is : find the correct place - the correct 0x09 to change.
                      What you'll be seeing : you have the original C language at your disposal, as it is "open source" so accessible for everybody.
                      Initially, you could use a disassemble program like ghidra so you know in what part of the code you have to look. Ghidra produces "Intel" processor instructions assembly source files from binary executables,
                      Intel X86 (probably the 64 version)is world's most used processor, also very open and accessible ***

                      You have to find the processor instructions that were compiled from the source, so you know the exact place of the 0x09 your looking for.

                      Now use the hex editor, hunt down the same byte sequence, and the 0x09, and change it to 0x19.

                      Done.

                      Some hints : the value might be found in the executable code itself, as it is probably part of and "immediate" addressing mode - its not a variable.
                      If you changed the wrong "09", you'll be good for some spectacular effects.

                      **** well ... it's actually the world's most disgusting instruction set processor. It's a pure mess.
                      Why (๐Ÿ˜ข sniff) wasn't the 68000 any good ?

                      No "help me" PM's please. Use the forum, the community will thank you.
                      Edit : and where are the logs ??

                      1 Reply Last reply Reply Quote 0
                      • stephenw10S
                        stephenw10 Netgate Administrator
                        last edited by

                        Hmm, hard to recommend hex editing the binary! ๐Ÿ˜‰

                        1 Reply Last reply Reply Quote 0
                        • bmeeksB
                          bmeeks
                          last edited by

                          Yeah, while hex editing on a binary can work every now and then, one problem I foresee in this particular case is that the PPPOE_CONNECT_TIMEOUT constant is defined once but then will possibly be used in a several places in the code. Finding all of those would be a tedious exercise. Edit the wrong 0x09 value somewhere and you would create a potentially serious bug.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.