Gentoo Archives: gentoo-dev

From: "Anthony G. Basile" <basile@××××××××××××××.edu>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Building against /usr/src/linux and linux-info.eclass
Date: Thu, 21 Feb 2013 23:47:04
Message-Id: 5126B1DF.3030708@opensource.dyc.edu
In Reply to: Re: [gentoo-dev] Building against /usr/src/linux and linux-info.eclass by Doug Goldstein
1 On 02/21/2013 06:12 PM, Doug Goldstein wrote:
2 > On Thu, Feb 21, 2013 at 12:42 PM, Anthony G. Basile
3 > <basile@××××××××××××××.edu> wrote:
4 >> Hi everyone,
5 >>
6 >> This issue has come up in a few bugs so I want to bounce it off the
7 >> community. When building packages that need a configured kernel source
8 >> tree, many ebuilds inherit linux-info to find configuration info about the
9 >> kernel. However, there is the running kernel with its configuration
10 >> (/proc/config.gz if it exists), there is the kernel source tree
11 >> (/usr/src/linux if it exists and is configured) and both of these can be of
12 >> a different version than linux-headers. Since building modules consumes
13 >> headers from /usr/include/linux, but uses code from /usr/src/linux and then
14 >> these modules are expected to insmod against the running kernel, all of
15 >> which can be mismatched, we have a lot of room for breakage. Eg. bug
16 >> #458014.
17 >>
18 >> Any ideas about how to deal cleanly with situations like that?
19 >>
20 >> --
21 >> Anthony G. Basile, Ph. D.
22 >> Chair of Information Technology
23 >> D'Youville College
24 >> Buffalo, NY 14201
25 >> (716) 829-8197
26 >>
27 >
28 > Kernel modules never use /usr/include/linux. That's the uapi headers,
29 > which are now broken out in 3.7 and newer. Kernel modules always use
30 > /usr/src/linux.
31 >
32 > There have been a number of issues with the differences between the
33 > user space bits and the kernel space bits wrt to netfilter post 3.0,
34 > so its not surprising that a userspace component is trying to use
35 > /usr/include/linux to frame up a structure to pass into kernel space
36 > via netlink and running into an issue.
37 >
38 > This is one of the reasons behind kapi/uapi to make it clear you
39 > shouldn't play with or touch this field/structure/value from user
40 > space.
41 >
42
43 I'm not sure the separation is so clean. I know userland should only
44 use /usr/include/linux, but modules could source both indirectly via an
45 include from /usr/include/linux [1].
46
47 But there's still the issue between the running kernel and
48 /usr/src/linux? In the eclass, linux_config_path() first tries to find
49 /usr/src/linux/.config and then falls back on /proc/config.gz. This is
50 too hackly since packages building kernel modules could use the wrong
51 config file.
52
53
54 Ref.
55
56 [1] Take a look at Pablo's rewrite of a patch I submitted to get
57 <linux/netfilter_ipv4/nf_nat.h> into the kernel:
58
59 http://www.spinics.net/lists/netfilter-devel/msg19833.html
60
61 There he includes in <linux/netfilter_ipv4/nf_nat.h>
62
63 /usr/src/linux/include/net/netfilter/nf_conntrack_tuple.h
64
65 So even though the later is kapi, the division from uapi is not so clean.
66
67
68
69 --
70 Anthony G. Basile, Ph. D.
71 Chair of Information Technology
72 D'Youville College
73 Buffalo, NY 14201
74 (716) 829-8197