From: Alexander Aring <aar@pengutronix.de>
To: ptxdist@pengutronix.de
Subject: Re: [ptxdist] iproute2 build errors when updating to 4.6
Date: Tue, 24 May 2016 20:08:25 +0200 [thread overview]
Message-ID: <a723cd6f-1e2c-4322-7644-431b4aaafbef@pengutronix.de> (raw)
In-Reply-To: <44f85c5d-0697-06b1-2e8b-334ac67fa0b8@pengutronix.de>
Hi,
On 05/24/2016 05:24 PM, Alexander Aring wrote:
...
>
> According to the buildfail of "m_ipt.o", this should be fixed mainline
> somehow and can't working with the iptables include files which are
> copied into include dir of iproute2. :-/
>
from what I noticed from iptables git log, etc, they renamed
iptables_target to xtables_target etc, some function are not exported
from lib anymore (if they are still used in m_ipt.o then do a static
inline).
Nevertheless, here is the patch which "maybe?" should go mainline to
iproute2 to work with the new API header of iptables, but I didn't
tested it. :-)
---
diff --git a/tc/m_ipt.c b/tc/m_ipt.c
index d088f5e..098f610 100644
--- a/tc/m_ipt.c
+++ b/tc/m_ipt.c
@@ -14,7 +14,6 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <linux/if.h>
#include <iptables.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4/ip_tables.h>
@@ -51,7 +50,7 @@ static struct option original_opts[] = {
{0, 0, 0, 0}
};
-static struct iptables_target *t_list;
+static struct xtables_target *t_list;
static struct option *opts = original_opts;
static unsigned int global_option_offset;
#define OPTION_OFFSET 256
@@ -59,32 +58,21 @@ static unsigned int global_option_offset;
char *lib_dir;
void
-register_target(struct iptables_target *me)
+xtables_register_target(struct xtables_target *me)
{
-/* fprintf(stderr, "\nDummy register_target %s\n", me->name);
-*/
me->next = t_list;
t_list = me;
}
-void
-xtables_register_target(struct iptables_target *me)
-{
- me->next = t_list;
- t_list = me;
-}
-
-void
-exit_tryhelp(int status)
+static void exit_tryhelp(int status)
{
fprintf(stderr, "Try `%s -h' or '%s --help' for more information.\n",
pname, pname);
exit(status);
}
-void
-exit_error(enum exittype status, char *msg, ...)
+static void exit_error(enum xtables_exittype status, char *msg, ...)
{
va_list args;
@@ -106,61 +94,6 @@ They should really have them as a library so i can link to them
Email them next time i remember
*/
-char *
-addr_to_dotted(const struct in_addr *addrp)
-{
- static char buf[20];
- const unsigned char *bytep;
-
- bytep = (const unsigned char *) &(addrp->s_addr);
- sprintf(buf, "%d.%d.%d.%d", bytep[0], bytep[1], bytep[2], bytep[3]);
- return buf;
-}
-
-int string_to_number_ll(const char *s, unsigned long long min,
- unsigned long long max,
- unsigned long long *ret)
-{
- unsigned long long number;
- char *end;
-
- /* Handle hex, octal, etc. */
- errno = 0;
- number = strtoull(s, &end, 0);
- if (*end == '\0' && end != s) {
- /* we parsed a number, let's see if we want this */
- if (errno != ERANGE && min <= number && (!max || number <= max)) {
- *ret = number;
- return 0;
- }
- }
- return -1;
-}
-
-int string_to_number_l(const char *s, unsigned long min, unsigned long max,
- unsigned long *ret)
-{
- int result;
- unsigned long long number;
-
- result = string_to_number_ll(s, min, max, &number);
- *ret = (unsigned long)number;
-
- return result;
-}
-
-int string_to_number(const char *s, unsigned int min, unsigned int max,
- unsigned int *ret)
-{
- int result;
- unsigned long number;
-
- result = string_to_number_l(s, min, max, &number);
- *ret = (unsigned int)number;
-
- return result;
-}
-
static void free_opts(struct option *local_opts)
{
if (local_opts != original_opts) {
@@ -205,10 +138,10 @@ fw_calloc(size_t count, size_t size)
return p;
}
-static struct iptables_target *
+static struct xtables_target *
find_t(char *name)
{
- struct iptables_target *m;
+ struct xtables_target *m;
for (m = t_list; m; m = m->next) {
if (strcmp(m->name, name) == 0)
@@ -218,13 +151,13 @@ find_t(char *name)
return NULL;
}
-static struct iptables_target *
+static struct xtables_target *
get_target_name(const char *name)
{
void *handle;
char *error;
char *new_name, *lname;
- struct iptables_target *m;
+ struct xtables_target *m;
char path[strlen(lib_dir) + sizeof("/libipt_.so") + strlen(name)];
#ifdef NO_SHARED_LIBS
@@ -291,7 +224,7 @@ get_target_name(const char *name)
m = dlsym(handle, new_name);
if ((error = dlerror()) != NULL) {
- m = (struct iptables_target *) dlsym(handle, lname);
+ m = (struct xtables_target *) dlsym(handle, lname);
if ((error = dlerror()) != NULL) {
m = find_t(new_name);
if (m == NULL) {
@@ -313,42 +246,6 @@ get_target_name(const char *name)
return m;
}
-
-struct in_addr *dotted_to_addr(const char *dotted)
-{
- static struct in_addr addr;
- unsigned char *addrp;
- char *p, *q;
- unsigned int onebyte;
- int i;
- char buf[20];
-
- /* copy dotted string, because we need to modify it */
- strncpy(buf, dotted, sizeof(buf) - 1);
- addrp = (unsigned char *) &(addr.s_addr);
-
- p = buf;
- for (i = 0; i < 3; i++) {
- if ((q = strchr(p, '.')) == NULL)
- return (struct in_addr *) NULL;
-
- *q = '\0';
- if (string_to_number(p, 0, 255, &onebyte) == -1)
- return (struct in_addr *) NULL;
-
- addrp[i] = (unsigned char) onebyte;
- p = q + 1;
- }
-
- /* we've checked 3 bytes, now we check the last one */
- if (string_to_number(p, 0, 255, &onebyte) == -1)
- return (struct in_addr *) NULL;
-
- addrp[3] = (unsigned char) onebyte;
-
- return &addr;
-}
-
static void set_revision(char *name, u_int8_t revision)
{
/* Old kernel sources don't have ".revision" field,
@@ -360,23 +257,20 @@ static void set_revision(char *name, u_int8_t revision)
/*
* we may need to check for version mismatch
*/
-int
-build_st(struct iptables_target *target, struct ipt_entry_target *t)
+static int build_st(struct xtables_target *target, struct ipt_entry_target *t)
{
- unsigned int nfcache = 0;
-
if (target) {
size_t size;
size =
- IPT_ALIGN(sizeof(struct ipt_entry_target)) + target->size;
+ XT_ALIGN(sizeof(struct ipt_entry_target)) + target->size;
if (t == NULL) {
target->t = fw_calloc(1, size);
target->t->u.target_size = size;
if (target->init != NULL)
- target->init(target->t, &nfcache);
+ target->init(target->t);
set_revision(target->t->u.user.name, target->revision);
} else {
target->t = t;
@@ -391,7 +285,7 @@ build_st(struct iptables_target *target, struct ipt_entry_target *t)
static int parse_ipt(struct action_util *a, int *argc_p,
char ***argv_p, int tca_id, struct nlmsghdr *n)
{
- struct iptables_target *m = NULL;
+ struct xtables_target *m = NULL;
struct ipt_entry fw;
struct rtattr *tail;
int c;
@@ -574,7 +468,7 @@ print_ipt(struct action_util *au, FILE * f, struct rtattr *arg)
fprintf(f, "\t[NULL ipt target parameters ]\n");
return -1;
} else {
- struct iptables_target *m = NULL;
+ struct xtables_target *m = NULL;
t = RTA_DATA(tb[TCA_IPT_TARG]);
m = get_target_name(t->u.user.name);
- Alex
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
next prev parent reply other threads:[~2016-05-24 18:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-21 23:55 Clemens Gruber
2016-05-24 7:20 ` Alexander Aring
2016-05-24 7:30 ` Alexander Aring
2016-05-24 13:01 ` Clemens Gruber
2016-05-24 15:24 ` Alexander Aring
2016-05-24 18:08 ` Alexander Aring [this message]
2016-05-25 17:42 ` Clemens Gruber
2016-05-29 18:31 ` Alexander Aring
2016-05-30 19:59 ` Clemens Gruber
2016-06-15 18:37 ` Alexander Aring
2016-06-16 16:19 ` Clemens Gruber
2016-05-24 10:04 ` Michael Olbrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a723cd6f-1e2c-4322-7644-431b4aaafbef@pengutronix.de \
--to=aar@pengutronix.de \
--cc=ptxdist@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox