Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
Dnsmasq
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Dnsmasq
Commits
d5052fb2
Commit
d5052fb2
authored
Apr 25, 2013
by
Simon Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix FTBFS in ipset.c with old kernel headers.
parent
b5a7ff42
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
15 deletions
+42
-15
CHANGELOG
CHANGELOG
+3
-0
src/ipset.c
src/ipset.c
+39
-15
No files found.
CHANGELOG
View file @
d5052fb2
...
@@ -18,6 +18,9 @@ version 2.67
...
@@ -18,6 +18,9 @@ version 2.67
Add --synth-domain. Thanks to Vishvananda Ishaya for
Add --synth-domain. Thanks to Vishvananda Ishaya for
suggesting this.
suggesting this.
Fix failure to compile ipset.c if old kernel headers are
in use. Thanks to Eugene Rudoy for pointing this out.
version 2.66
version 2.66
...
...
src/ipset.c
View file @
d5052fb2
...
@@ -26,9 +26,12 @@
...
@@ -26,9 +26,12 @@
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <linux/version.h>
#include <linux/version.h>
#include <linux/netlink.h>
#include <linux/netlink.h>
#include <linux/netfilter/nfnetlink.h>
#ifndef NFNL_SUBSYS_IPSET
/* We want to be able to compile against old header files
Kernel version is handled at run-time. */
#define NFNL_SUBSYS_IPSET 6
#define NFNL_SUBSYS_IPSET 6
#define IPSET_ATTR_DATA 7
#define IPSET_ATTR_DATA 7
#define IPSET_ATTR_IP 1
#define IPSET_ATTR_IP 1
#define IPSET_ATTR_IPADDR_IPV4 1
#define IPSET_ATTR_IPADDR_IPV4 1
...
@@ -39,10 +42,31 @@
...
@@ -39,10 +42,31 @@
#define IPSET_CMD_DEL 10
#define IPSET_CMD_DEL 10
#define IPSET_MAXNAMELEN 32
#define IPSET_MAXNAMELEN 32
#define IPSET_PROTOCOL 6
#define IPSET_PROTOCOL 6
#else
#include <linux/netfilter/ipset/ip_set.h>
#ifndef NFNETLINK_V0
#define NFNETLINK_V0 0
#endif
#ifndef NLA_F_NESTED
#define NLA_F_NESTED (1 << 15)
#endif
#endif
#ifndef NLA_F_NET_BYTEORDER
#define NLA_F_NET_BYTEORDER (1 << 14)
#endif
struct
my_nlattr
{
__u16
nla_len
;
__u16
nla_type
;
};
struct
my_nfgenmsg
{
__u8
nfgen_family
;
/* AF_xxx */
__u8
version
;
/* nfnetlink version */
__be16
res_id
;
/* resource id */
};
/* data structure size in here is fixed */
/* data structure size in here is fixed */
#define BUFF_SZ 256
#define BUFF_SZ 256
...
@@ -53,11 +77,11 @@ static char *buffer;
...
@@ -53,11 +77,11 @@ static char *buffer;
static
inline
void
add_attr
(
struct
nlmsghdr
*
nlh
,
uint16_t
type
,
size_t
len
,
const
void
*
data
)
static
inline
void
add_attr
(
struct
nlmsghdr
*
nlh
,
uint16_t
type
,
size_t
len
,
const
void
*
data
)
{
{
struct
nlattr
*
attr
=
(
void
*
)
nlh
+
NL_ALIGN
(
nlh
->
nlmsg_len
);
struct
my_
nlattr
*
attr
=
(
void
*
)
nlh
+
NL_ALIGN
(
nlh
->
nlmsg_len
);
uint16_t
payload_len
=
NL_ALIGN
(
sizeof
(
struct
nlattr
))
+
len
;
uint16_t
payload_len
=
NL_ALIGN
(
sizeof
(
struct
my_
nlattr
))
+
len
;
attr
->
nla_type
=
type
;
attr
->
nla_type
=
type
;
attr
->
nla_len
=
payload_len
;
attr
->
nla_len
=
payload_len
;
memcpy
((
void
*
)
attr
+
NL_ALIGN
(
sizeof
(
struct
nlattr
)),
data
,
len
);
memcpy
((
void
*
)
attr
+
NL_ALIGN
(
sizeof
(
struct
my_
nlattr
)),
data
,
len
);
nlh
->
nlmsg_len
+=
NL_ALIGN
(
payload_len
);
nlh
->
nlmsg_len
+=
NL_ALIGN
(
payload_len
);
}
}
...
@@ -93,8 +117,8 @@ void ipset_init(void)
...
@@ -93,8 +117,8 @@ void ipset_init(void)
static
int
new_add_to_ipset
(
const
char
*
setname
,
const
struct
all_addr
*
ipaddr
,
int
af
,
int
remove
)
static
int
new_add_to_ipset
(
const
char
*
setname
,
const
struct
all_addr
*
ipaddr
,
int
af
,
int
remove
)
{
{
struct
nlmsghdr
*
nlh
;
struct
nlmsghdr
*
nlh
;
struct
nfgenmsg
*
nfg
;
struct
my_
nfgenmsg
*
nfg
;
struct
nlattr
*
nested
[
2
];
struct
my_
nlattr
*
nested
[
2
];
uint8_t
proto
;
uint8_t
proto
;
int
addrsz
=
INADDRSZ
;
int
addrsz
=
INADDRSZ
;
ssize_t
rc
;
ssize_t
rc
;
...
@@ -117,8 +141,8 @@ static int new_add_to_ipset(const char *setname, const struct all_addr *ipaddr,
...
@@ -117,8 +141,8 @@ static int new_add_to_ipset(const char *setname, const struct all_addr *ipaddr,
nlh
->
nlmsg_type
=
(
remove
?
IPSET_CMD_DEL
:
IPSET_CMD_ADD
)
|
(
NFNL_SUBSYS_IPSET
<<
8
);
nlh
->
nlmsg_type
=
(
remove
?
IPSET_CMD_DEL
:
IPSET_CMD_ADD
)
|
(
NFNL_SUBSYS_IPSET
<<
8
);
nlh
->
nlmsg_flags
=
NLM_F_REQUEST
;
nlh
->
nlmsg_flags
=
NLM_F_REQUEST
;
nfg
=
(
struct
nfgenmsg
*
)(
buffer
+
nlh
->
nlmsg_len
);
nfg
=
(
struct
my_
nfgenmsg
*
)(
buffer
+
nlh
->
nlmsg_len
);
nlh
->
nlmsg_len
+=
NL_ALIGN
(
sizeof
(
struct
nfgenmsg
));
nlh
->
nlmsg_len
+=
NL_ALIGN
(
sizeof
(
struct
my_
nfgenmsg
));
nfg
->
nfgen_family
=
af
;
nfg
->
nfgen_family
=
af
;
nfg
->
version
=
NFNETLINK_V0
;
nfg
->
version
=
NFNETLINK_V0
;
nfg
->
res_id
=
htons
(
0
);
nfg
->
res_id
=
htons
(
0
);
...
@@ -126,11 +150,11 @@ static int new_add_to_ipset(const char *setname, const struct all_addr *ipaddr,
...
@@ -126,11 +150,11 @@ static int new_add_to_ipset(const char *setname, const struct all_addr *ipaddr,
proto
=
IPSET_PROTOCOL
;
proto
=
IPSET_PROTOCOL
;
add_attr
(
nlh
,
IPSET_ATTR_PROTOCOL
,
sizeof
(
proto
),
&
proto
);
add_attr
(
nlh
,
IPSET_ATTR_PROTOCOL
,
sizeof
(
proto
),
&
proto
);
add_attr
(
nlh
,
IPSET_ATTR_SETNAME
,
strlen
(
setname
)
+
1
,
setname
);
add_attr
(
nlh
,
IPSET_ATTR_SETNAME
,
strlen
(
setname
)
+
1
,
setname
);
nested
[
0
]
=
(
struct
nlattr
*
)(
buffer
+
NL_ALIGN
(
nlh
->
nlmsg_len
));
nested
[
0
]
=
(
struct
my_
nlattr
*
)(
buffer
+
NL_ALIGN
(
nlh
->
nlmsg_len
));
nlh
->
nlmsg_len
+=
NL_ALIGN
(
sizeof
(
struct
nlattr
));
nlh
->
nlmsg_len
+=
NL_ALIGN
(
sizeof
(
struct
my_
nlattr
));
nested
[
0
]
->
nla_type
=
NLA_F_NESTED
|
IPSET_ATTR_DATA
;
nested
[
0
]
->
nla_type
=
NLA_F_NESTED
|
IPSET_ATTR_DATA
;
nested
[
1
]
=
(
struct
nlattr
*
)(
buffer
+
NL_ALIGN
(
nlh
->
nlmsg_len
));
nested
[
1
]
=
(
struct
my_
nlattr
*
)(
buffer
+
NL_ALIGN
(
nlh
->
nlmsg_len
));
nlh
->
nlmsg_len
+=
NL_ALIGN
(
sizeof
(
struct
nlattr
));
nlh
->
nlmsg_len
+=
NL_ALIGN
(
sizeof
(
struct
my_
nlattr
));
nested
[
1
]
->
nla_type
=
NLA_F_NESTED
|
IPSET_ATTR_IP
;
nested
[
1
]
->
nla_type
=
NLA_F_NESTED
|
IPSET_ATTR_IP
;
add_attr
(
nlh
,
add_attr
(
nlh
,
(
af
==
AF_INET
?
IPSET_ATTR_IPADDR_IPV4
:
IPSET_ATTR_IPADDR_IPV6
)
|
NLA_F_NET_BYTEORDER
,
(
af
==
AF_INET
?
IPSET_ATTR_IPADDR_IPV4
:
IPSET_ATTR_IPADDR_IPV6
)
|
NLA_F_NET_BYTEORDER
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment