diff mbox series

[ethtool,1/3] misc: Fix build with kernel headers < v4.11

Message ID 20230113233148.235543-2-f.fainelli@gmail.com (mailing list archive)
State Superseded
Delegated to: Michal Kubecek
Headers show
Series Build fixes for older kernel headers and musl | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Florian Fainelli Jan. 13, 2023, 11:31 p.m. UTC
Not all toolchain kernel headers may contain upstream commit
2618be7dccf8739b89e1906b64bd8d551af351e6 ("uapi: fix linux/if.h
userspace compilation errors") which is included in v4.11 and onwards.
Err on the side of caution by including sys/socket.h ahead of including
linux/if.h.

Fixes: 1fa60003a8b8 ("misc: header includes cleanup")
Reported-by: Markus Mayer <mmayer@broadcom.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 internal.h | 1 +
 1 file changed, 1 insertion(+)

Comments

Michal Kubecek Jan. 13, 2023, 11:57 p.m. UTC | #1
On Fri, Jan 13, 2023 at 03:31:46PM -0800, Florian Fainelli wrote:
> Not all toolchain kernel headers may contain upstream commit
> 2618be7dccf8739b89e1906b64bd8d551af351e6 ("uapi: fix linux/if.h
> userspace compilation errors") which is included in v4.11 and onwards.
> Err on the side of caution by including sys/socket.h ahead of including
> linux/if.h.
> 
> Fixes: 1fa60003a8b8 ("misc: header includes cleanup")
> Reported-by: Markus Mayer <mmayer@broadcom.com>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  internal.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/internal.h b/internal.h
> index b80f77afa4c0..f7aaaf5229f4 100644
> --- a/internal.h
> +++ b/internal.h
> @@ -21,6 +21,7 @@
>  #include <unistd.h>
>  #include <endian.h>
>  #include <sys/ioctl.h>
> +#include <sys/socket.h>
>  #include <linux/if.h>
>  
>  #include "json_writer.h"

No objection but I wonder if it wouldn't make sense to add linux/if.h to
the header copies in uapi/ instead as then we could also drop the
fallback definition of ALTIFNAMSIZ and perhaps more similar hacks.

Michal
Florian Fainelli Jan. 14, 2023, 12:11 a.m. UTC | #2
On 1/13/2023 3:57 PM, Michal Kubecek wrote:
> On Fri, Jan 13, 2023 at 03:31:46PM -0800, Florian Fainelli wrote:
>> Not all toolchain kernel headers may contain upstream commit
>> 2618be7dccf8739b89e1906b64bd8d551af351e6 ("uapi: fix linux/if.h
>> userspace compilation errors") which is included in v4.11 and onwards.
>> Err on the side of caution by including sys/socket.h ahead of including
>> linux/if.h.
>>
>> Fixes: 1fa60003a8b8 ("misc: header includes cleanup")
>> Reported-by: Markus Mayer <mmayer@broadcom.com>
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>>   internal.h | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/internal.h b/internal.h
>> index b80f77afa4c0..f7aaaf5229f4 100644
>> --- a/internal.h
>> +++ b/internal.h
>> @@ -21,6 +21,7 @@
>>   #include <unistd.h>
>>   #include <endian.h>
>>   #include <sys/ioctl.h>
>> +#include <sys/socket.h>
>>   #include <linux/if.h>
>>   
>>   #include "json_writer.h"
> 
> No objection but I wonder if it wouldn't make sense to add linux/if.h to
> the header copies in uapi/ instead as then we could also drop the
> fallback definition of ALTIFNAMSIZ and perhaps more similar hacks.

Humm, I wondered about that but it seems like opening a possible can of 
worms as the history of include/uapi/linux/if.h changed across multiple 
versions. As long as it does compile, why not :)
Florian Fainelli Jan. 14, 2023, 2:07 a.m. UTC | #3
On 1/13/2023 4:11 PM, Florian Fainelli wrote:
> 
> 
> On 1/13/2023 3:57 PM, Michal Kubecek wrote:
>> On Fri, Jan 13, 2023 at 03:31:46PM -0800, Florian Fainelli wrote:
>>> Not all toolchain kernel headers may contain upstream commit
>>> 2618be7dccf8739b89e1906b64bd8d551af351e6 ("uapi: fix linux/if.h
>>> userspace compilation errors") which is included in v4.11 and onwards.
>>> Err on the side of caution by including sys/socket.h ahead of including
>>> linux/if.h.
>>>
>>> Fixes: 1fa60003a8b8 ("misc: header includes cleanup")
>>> Reported-by: Markus Mayer <mmayer@broadcom.com>
>>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>>> ---
>>>   internal.h | 1 +
>>>   1 file changed, 1 insertion(+)
>>>
>>> diff --git a/internal.h b/internal.h
>>> index b80f77afa4c0..f7aaaf5229f4 100644
>>> --- a/internal.h
>>> +++ b/internal.h
>>> @@ -21,6 +21,7 @@
>>>   #include <unistd.h>
>>>   #include <endian.h>
>>>   #include <sys/ioctl.h>
>>> +#include <sys/socket.h>
>>>   #include <linux/if.h>
>>>   #include "json_writer.h"
>>
>> No objection but I wonder if it wouldn't make sense to add linux/if.h to
>> the header copies in uapi/ instead as then we could also drop the
>> fallback definition of ALTIFNAMSIZ and perhaps more similar hacks.
> 
> Humm, I wondered about that but it seems like opening a possible can of 
> worms as the history of include/uapi/linux/if.h changed across multiple 
> versions. As long as it does compile, why not :)

Just to be clear, I will give that one a shot and let you know how it 
goes, if it works fine, then it will be in v2.
diff mbox series

Patch

diff --git a/internal.h b/internal.h
index b80f77afa4c0..f7aaaf5229f4 100644
--- a/internal.h
+++ b/internal.h
@@ -21,6 +21,7 @@ 
 #include <unistd.h>
 #include <endian.h>
 #include <sys/ioctl.h>
+#include <sys/socket.h>
 #include <linux/if.h>
 
 #include "json_writer.h"