Bug 282780 - emulators/virtualbox-ose-kmod: build error since 1500027 (struct ifnet is now hidden)
Summary: emulators/virtualbox-ose-kmod: build error since 1500027 (struct ifnet is now...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Vladimir Druzenko
URL:
Keywords:
Depends on:
Blocks: 271146
  Show dependency treegraph
 
Reported: 2024-11-15 11:03 UTC by Olivier Cochard
Modified: 2025-01-04 18:33 UTC (History)
6 users (show)

See Also:
bugzilla: maintainer-feedback? (vbox)


Attachments
ifnet.patch (13.97 KB, patch)
2024-11-27 15:28 UTC, Vladimir Kondratyev
no flags Details | Diff
ifnet.patch (13.96 KB, patch)
2024-11-27 15:51 UTC, Vladimir Kondratyev
no flags Details | Diff
emulators/virtualbox-ose-legacy v1 (18.92 KB, patch)
2024-12-24 19:17 UTC, Vladimir Druzenko
no flags Details | Diff
emulators/virtualbox-ose-legacy v2 (18.87 KB, patch)
2024-12-24 23:56 UTC, Vladimir Druzenko
no flags Details | Diff
emulators/virtualbox-ose v1 (17.91 KB, patch)
2024-12-24 23:56 UTC, Vladimir Druzenko
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Cochard freebsd_committer freebsd_triage 2024-11-15 11:03:42 UTC
Hi,

looks like a long due change switch to default on current:
https://lists.freebsd.org/archives/freebsd-net/2024-November/005983.html

--- VBoxNetFlt-freebsd.o ---
VBoxNetFlt-freebsd.c:343:24: error: incomplete definition of type 'struct ifnet'
  343 |     VBOXCURVNET_SET(ifp->if_vnet);
      |                     ~~~^
Comment 1 Vladimir Druzenko freebsd_committer freebsd_triage 2024-11-16 00:52:11 UTC
Can you suggest a patch?
Comment 2 Ken DEGUCHI 2024-11-18 08:58:31 UTC
(In reply to Vladimir Druzenko from comment #1)

As far as I have tried,

#include <net/if_private.h>

to the following two files, it seems to build and use them without any problem.

${WRKSRC}/src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c
${WRKSRC}/src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c
Comment 3 Olivier Cochard freebsd_committer freebsd_triage 2024-11-18 17:00:42 UTC
(In reply to Ken DEGUCHI from comment #2)

The current plan is to remove inclusion of if_private.h
Comment 4 Vladimir Druzenko freebsd_committer freebsd_triage 2024-11-18 22:06:10 UTC
(In reply to Olivier Cochard from comment #3)
Okay, you told how not to do it. Can you tell how to do? :-D
Comment 5 Olivier Cochard freebsd_committer freebsd_triage 2024-11-18 22:22:26 UTC
(In reply to Vladimir Druzenko from comment #4)

Yes because it is a lot more easy to tell how to not doing it :-)

Following this announcement:
https://lists.freebsd.org/archives/freebsd-net/2024-November/005983.html

There is an helper script in instruction, but you need some coding skills which I don’t have.

cd /usr/ports/emulators/virtualbox-ose-kmod/
make patch
cd work/VirtualBox-6.1.50
/usr/src/tools/ifnet/convert_ifapi.sh ./src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c

Conversion for ./src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c started, please wait:  \
       7 lines could not be converted to IFAPI
Look for /* XXX - IFAPI */ in the converted file

And this is where my skillset end :-)

I would start looking for all existing NIC drivers that were migrated by listing all commit with the name "IfAPI":
https://cgit.freebsd.org/src/log/?qt=grep&q=IfAPI
Comment 6 Justin Hibbits freebsd_committer freebsd_triage 2024-11-19 15:07:31 UTC
The "easy" thing to do after running the script on the file is to check:

* Any place you see foo->if_xxx = <N>, look for a if_setxxx in net/if_var.h.  If something doesn't exist, there may be an equivalent, or a new API may be needed.
* Any place you see N = foo->if_xxx, look for if_getxxx in net/if_var.h.

Now, there will probably be cases where the script messed up the conversion, and you went from something like:

   xxx_ifp->if_mtu = 42;

to:

   xxx_if_setmtu(ifp, 42);

This needs cleaned up to:

   if_setmtu(xxx_ifp, 42);


These above are the most common issues with the conversion script.  If you still have issues after applying changes I listed here, please let me know, either filing a PR, or email (freebsd-net list, CC me).  Since all in-tree drivers have been converted to IfAPI, the vast majority of use cases have been dealt with, and any new cases found are likely very special-case, so would be handled as needed.
Comment 7 Vladimir Kondratyev freebsd_committer freebsd_triage 2024-11-27 15:28:40 UTC
Created attachment 255491 [details]
ifnet.patch

Mechanical conversion to new ifnet KPI
Comment 8 Vladimir Kondratyev freebsd_committer freebsd_triage 2024-11-27 15:32:26 UTC
There may be more 'struct ifnet *' -> if_t conversion required but I am too lazy to do it
Comment 9 Justin Hibbits freebsd_committer freebsd_triage 2024-11-27 15:39:37 UTC
(In reply to Vladimir Kondratyev from comment #7)

Thanks for doing the work, one comment, though:

* You changed `struct ifnet *` to `if_t *`, but `if_t` is `struct ifnet *`, so `if_t *` is a pointer to a pointer now.  You just want `if_t foo` instead.
Comment 10 Vladimir Kondratyev freebsd_committer freebsd_triage 2024-11-27 15:51:48 UTC
Created attachment 255492 [details]
ifnet.patch

if_t * -> if_t
Comment 11 Justin Hibbits freebsd_committer freebsd_triage 2024-11-27 16:00:48 UTC
(In reply to Vladimir Kondratyev from comment #10)

Looks good.  Might want to make that patch conditional on the FreeBSD version in the port, though.  If it's just supporting FreeBSD 14 and later, though, I think you can skip it, since almost everything has been in place since FreeBSD 14 was still -CURRENT.
Comment 12 Vladimir Kondratyev freebsd_committer freebsd_triage 2024-11-28 09:24:13 UTC
It seems that 13-STABLE implements most or may be all of interfaces required by the patch. Someone running FreeBSD 13 should check that.
Comment 13 Vladimir Druzenko freebsd_committer freebsd_triage 2024-12-22 18:20:06 UTC
I can commit this patch, but I can't test it - I don't have hosts with 15-CURRENT.
Now I can test build on 13.4 and 14.1 only. Run on 14.1. Update to 14.2 planned on NY holidays.
Can anyone help with testing on 15-CURRENT?
Comment 14 groenveld 2024-12-23 16:47:11 UTC
(In reply to Vladimir Druzenko from comment #13)

Worked for me.
$ uname -srv
FreeBSD 15.0-CURRENT FreeBSD 15.0-CURRENT #0 main-n274384-371a4ee9a384: Thu Dec 19 07:11:42 UTC 2024     root@releng3.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
$ VBoxManage --version
6.1.50r161033

John
groenveld@acm.org
Comment 15 Vladimir Druzenko freebsd_committer freebsd_triage 2024-12-24 16:03:29 UTC
(In reply to groenveld from comment #14)
Tested build and work emulators/virtualbox-ose-kmod on live system 14.1.
Testing build in poudriere 13.4.

I have to apply it to emulators/virtualbox-ose-kmod-legacy.
Comment 16 Vladimir Druzenko freebsd_committer freebsd_triage 2024-12-24 17:35:31 UTC
Error in 13.4:
VBoxNetFlt-freebsd.c:343:5: error: incompatible integer to pointer conversion assigning to 'struct vnet *' from 'int' [-Wint-conversion]
  343 |     VBOXCURVNET_SET(if_getvnet(ifp));
      |     ^               ~~~~~~~~~~~~~~~
VBoxNetFlt-freebsd.c:451:5: error: incompatible integer to pointer conversion assigning to 'struct vnet *' from 'int' [-Wint-conversion]
  451 |     VBOXCURVNET_SET(if_getvnet(ifp));
      |     ^               ~~~~~~~~~~~~~~~
Comment 17 Vladimir Druzenko freebsd_committer freebsd_triage 2024-12-24 19:17:37 UTC
Created attachment 256112 [details]
emulators/virtualbox-ose-legacy v1

Tested build on 13.4 and 14.1 amd64 (test build on i386 in progress).
Need testing on recent 15-CURRENT.

Patch for emulators/virtualbox-ose I'll create later.
Comment 18 Vladimir Druzenko freebsd_committer freebsd_triage 2024-12-24 23:56:03 UTC
Created attachment 256117 [details]
emulators/virtualbox-ose-legacy v2

emulators/virtualbox-ose-kmod-legacy: tested build in poudriere 13.4 and 14.1, i386 and amd64.
Need testing on recent 15-CURRENT.
Comment 19 Vladimir Druzenko freebsd_committer freebsd_triage 2024-12-24 23:56:54 UTC
Created attachment 256118 [details]
emulators/virtualbox-ose v1

emulators/virtualbox-ose-kmod: tested build in poudriere 13.4 and 14.1 amd64.
Need testing on recent 15-CURRENT.
Comment 20 groenveld 2024-12-25 02:21:36 UTC
(In reply to Vladimir Druzenko from comment #18)

Worked for me.
$ uname -srv
FreeBSD 15.0-CURRENT FreeBSD 15.0-CURRENT #0 main-n274384-371a4ee9a384: Thu Dec 19 07:11:42 UTC 2024     root@releng3.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
$ VBoxManage --version
5.2.44r139111

John
groenveld@acm.org
Comment 21 groenveld 2024-12-25 02:35:37 UTC
(In reply to Vladimir Druzenko from comment #19)

This worked for me too...thank you!
$ uname -srv
FreeBSD 15.0-CURRENT FreeBSD 15.0-CURRENT #0 main-n274384-371a4ee9a384: Thu Dec 19 07:11:42 UTC 2024     root@releng3.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC

$ VBoxManage --version
6.1.50r161033

John
groenveld@acm.org
Comment 22 commit-hook freebsd_committer freebsd_triage 2024-12-25 09:51:52 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3528379355540d3fa2c7c1aee40963742016303a

commit 3528379355540d3fa2c7c1aee40963742016303a
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2024-12-25 09:48:45 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-12-25 09:48:45 +0000

    emulators/virtualbox-ose-kmod-legacy: Fix build error since 1500027 (struct ifnet is now hidden)

    Based on patch from wulf.

    PR:             282780
    Tested by:      groenveld@acm.org

 ...Drivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c | 137 ++++++++++++-
 ...Drivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c | 215 ++++++++++++++++++---
 2 files changed, 326 insertions(+), 26 deletions(-)
Comment 23 commit-hook freebsd_committer freebsd_triage 2024-12-25 09:51:55 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=1b244fbbf4d6340c647b5ee550347b0acb175f11

commit 1b244fbbf4d6340c647b5ee550347b0acb175f11
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2024-12-25 09:37:37 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-12-25 09:37:37 +0000

    emulators/virtualbox-ose-kmod: Fix build error since 1500027 (struct ifnet is now hidden)

    Based on patch from wulf.

    PR:             282780
    Tested by:      groenveld@acm.org

 ...oxNetAdp_freebsd_VBoxNetAdp-freebsd.c.bak (new) | 147 +++++++++++++++
 ...Drivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c | 209 ++++++++++++++++++---
 2 files changed, 335 insertions(+), 21 deletions(-)
Comment 24 Vladimir Druzenko freebsd_committer freebsd_triage 2024-12-25 09:56:01 UTC
Thanks!
Comment 25 commit-hook freebsd_committer freebsd_triage 2025-01-04 18:33:03 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7481fae4ff18b9843153b41470ea1dc910c6c311

commit 7481fae4ff18b9843153b41470ea1dc910c6c311
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2025-01-04 18:30:10 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2025-01-04 18:30:10 +0000

    emulators/virtualbox-ose: Rename patch from *.bak to *

    PR:     282780
    Fixes:  1b244fbbf4d6 (Fix build error since 1500027 (struct ifnet is now hidden))

 ...=> patch-src_VBox_HostDrivers_VBoxNetAdp_freebsd_VBoxNetAdp-freebsd.c} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)