Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Cannot build on FreeBSD 11-CURRENT #60

Closed
mkushnir opened this Issue Jan 12, 2016 · 2 comments

Comments

Projects
None yet
2 participants
Contributor

mkushnir commented Jan 12, 2016

When building on a not so old 11-CURRENT, I'm getting this:

cc -fPIC -fno-strict-aliasing -D_GNU_SOURCE -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2  -Wall -O2 -g -DPCP_DEBUG -DPCP_VERSION=\"3.11.0\" -I../../../src/include -I../../../src/include/pcp   -c -o netif.o netif.c
netif.c:148:35: error: no member named 'if_data' in 'struct ifnet'
                    atom->ul = (__uint32_t)ifp->if_data.ifi_mtu;
                                           ~~~  ^
netif.c:156:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_baudrate;
                                ~~~  ^
netif.c:160:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_ibytes;
                                ~~~  ^
netif.c:164:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_ipackets;
                                ~~~  ^
netif.c:168:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_imcasts;
                                ~~~  ^
netif.c:172:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_ierrors;
                                ~~~  ^
netif.c:176:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_iqdrops;
                                ~~~  ^
netif.c:180:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_obytes;
                                ~~~  ^
netif.c:184:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_opackets;
                                ~~~  ^
netif.c:188:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_omcasts;
                                ~~~  ^
netif.c:192:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_oerrors;
                                ~~~  ^
netif.c:196:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_collisions;
                                ~~~  ^
netif.c:200:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_ibytes + ifp->if_data.ifi_obytes;
                                ~~~  ^
netif.c:200:50: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_ibytes + ifp->if_data.ifi_obytes;
                                                          ~~~  ^
netif.c:204:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_ipackets + ifp->if_data.ifi_opackets;
                                ~~~  ^
netif.c:204:52: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_ipackets + ifp->if_data.ifi_opackets;
                                                            ~~~  ^
netif.c:208:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_imcasts + ifp->if_data.ifi_omcasts;
                                ~~~  ^
netif.c:208:51: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_imcasts + ifp->if_data.ifi_omcasts;
                                                           ~~~  ^
netif.c:212:24: error: no member named 'if_data' in 'struct ifnet'
                    atom->ull = ifp->if_data.ifi_ierrors + ifp->if_data.ifi_oerrors;
                                ~~~  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
<builtin>: recipe for target 'netif.o' failed
gmake: *** [netif.o] Error 1

After some digging into it, looks like FreeBSD's kvm(3) was used, directly interpreting kernel memory structures. The interface turns out to be quite unstable. I would suggest to re-implement it using getifaddrs(3) API. The attached patch worked for me.
out.txt

Contributor

kmcdonell commented Jan 13, 2016

You're correct on a couple of fronts.

  1. using /dev/kmem was a throwback to Unix versions 20+ years ago ... rather than the plan of choice it is the fallback plan wired into my brain when ignorance hides a more modern API ... and I'm clearly not a FreeBSD guru.
  2. FreeBSD 11 is missing from my QA matrix.

Let me fix 2. then apply your patch (which looks OK from a quick scan), test and then I'll commit.

Thanks for taking the time and effort.

Contributor

kmcdonell commented Jan 14, 2016

Code based mostly on mkushnir's patch has been committed to my tree and will flow upsteam in due course (including to github).
Thanks.

@kmcdonell kmcdonell closed this Jan 14, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment