Page MenuHomeFreeBSD

wtap build error - missing header file
ClosedPublic

Authored by farhan_farhan.codes on May 9 2025, 3:51 AM.
Referenced Files
Unknown Object (File)
Mon, Jul 14, 5:22 AM
Unknown Object (File)
Sun, Jul 13, 10:25 PM
Unknown Object (File)
Sun, Jul 6, 11:34 AM
Unknown Object (File)
Sun, Jun 29, 12:10 PM
Unknown Object (File)
Sun, Jun 29, 3:05 AM
Unknown Object (File)
Thu, Jun 26, 3:34 PM
Unknown Object (File)
Wed, Jun 25, 2:44 PM
Unknown Object (File)
Wed, Jun 25, 9:31 AM

Details

Summary

It looks like wtap did not build, missing a header file.

On a side note, this project also is missing a man page.

On a sider note, this is almost exactly the same project I am working on here. Darn.
https://github.com/khanzf/i3e_driver

Test Plan

Try building without my modification:

make -C /usr/src/sys/modules/wtap

Then apply my patch and build and load

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

farhan_farhan.codes edited the test plan for this revision. (Show Details)
thj requested changes to this revision.May 9 2025, 8:56 AM
thj added a subscriber: thj.
thj added inline comments.
sys/dev/wtap/if_wtap.c
36–37

I didn't need to add these just if_private, can you try building without the includes too?

39

Can you add this after if_var, most files include these four headers in this order:

#include <net/if.h>
#include <net/if_var.h>
#include <net/if_private.h>
#include <net/vnet.h>

This is from dummybuf.c, but its the order in most files

This revision now requires changes to proceed.May 9 2025, 8:56 AM
bz requested changes to this revision.May 9 2025, 4:08 PM
bz added a reviewer: jhibbits.
bz added a subscriber: bz.
bz added inline comments.
sys/dev/wtap/if_wtap.c
39

wtap is a driver and does not belong to the core network stack. As such it should not use if_private.h but use accessor functions from if_var.h if I am not wrong.

This revision now requires changes to proceed.May 9 2025, 4:08 PM

I'm not sure why this was never connected to the build, I would have fixed it during my IfAPI work if it were connected then.

You can use the script tools/ifnet/convert_ifapi.sh to assist in converting the driver to IfAPI.

sys/dev/wtap/if_wtap.c
38

This is a private header. Please use the accessors in if_var.h.

jhibbits requested changes to this revision.May 9 2025, 4:57 PM

I'm not sure why this was never connected to the build, I would have fixed it during my IfAPI work if it were connected then.

You can use the script tools/ifnet/convert_ifapi.sh to assist in converting the driver to IfAPI.

Did you attach something in your comment?

I'm not sure why this was never connected to the build, I would have fixed it during my IfAPI work if it were connected then.

You can use the script tools/ifnet/convert_ifapi.sh to assist in converting the driver to IfAPI.

Hi,

I ran that script and it seemed to modify the make_dev line, specifically regarding the interface name.

I updated it as follows, which is in the spirit of what the script produces:

avp->av_dev = make_dev(&wtap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,                                                "%s", (const char *)vap->iv_ifp->if_xname);

Regarding not including if_private.h directly, not including it results in missing structs. Also, other code imports it directly.

If there is another way, what exact patterns of includes are you suggesting?

I updated it as follows, which is in the spirit of what the script produces:

avp->av_dev = make_dev(&wtap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,                                                "%s", (const char *)vap->iv_ifp->if_xname);

Regarding not including if_private.h directly, not including it results in missing structs. Also, other code imports it directly.

If there is another way, what exact patterns of includes are you suggesting?

I guess this is what we want:

diff --git a/sys/dev/wtap/if_wtap.c b/sys/dev/wtap/if_wtap.c
index 3aa3831e72c2..2b098bcc3dda 100644
--- a/sys/dev/wtap/if_wtap.c
+++ b/sys/dev/wtap/if_wtap.c
@@ -33,7 +33,7 @@
  */
 #include "if_wtapvar.h"
 #include <sys/uio.h>    /* uio struct */
-#include <sys/jail.h>
+#include <net/if.h>
 #include <net/if_var.h>
 #include <net/vnet.h>
 
@@ -395,7 +395,7 @@ wtap_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ],
        ieee80211_vap_attach(vap, ieee80211_media_change,
            ieee80211_media_status, mac);
        avp->av_dev = make_dev(&wtap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
-           "%s", (const char *)vap->iv_ifp->if_xname);
+           "%s", if_name(vap->iv_ifp));
        avp->av_dev->si_drv1 = sc;
        callout_init(&avp->av_swba, 0);
This revision was not accepted when it landed; it landed in state Needs Review.May 20 2025, 1:46 AM
Closed by commit rG0bab69859b32: wtap(4): Fix build (authored by farhan_farhan.codes, committed by lwhsu). · Explain Why
This revision was automatically updated to reflect the committed changes.