Linux Advanced Routing and Traffic Control list
 help / color / mirror / Atom feed
From: jeremie le-hen <le-hen_j@epita.fr>
To: lartc@vger.kernel.org
Subject: [LARTC] hexadecimal fwmark and fwmark mask
Date: Thu, 18 Sep 2003 13:46:38 +0000	[thread overview]
Message-ID: <marc-lartc-106389287809097@msgid-missing> (raw)

Hi list,

I'm new to this list, I just subscribed because I have some ackward
about IPRoute2.

First, while playing with NetFilter' "MARK" target, I met a weird
behaviour once I tried to use this marks in the RPDB : the packets
where successfully marked, but it seemed that RPDB didn't succed in
matching them (for those who already know the answer, I only used
marks above 9). After googling a while, I found that ip(8) only
accepts hexadecimal numbers for "fwmark" statement. IMHO, I think
that allowing only hexadecimal values in ip(8) while iptables(8)
allows to either use decimal or hexadecimal value is quite
inconsistent.
I checked ip(8) sources, and here is the point :

        } else if (strcmp(*argv, "fwmark") = 0) {
                __u32 fwmark;
                NEXT_ARG();
                if (get_u32(&fwmark, *argv, 16))
                        invarg("fwmark value is invalid\n", *argv);
                addattr32(&req.n, sizeof(req), RTA_PROTOINFO, fwmark);

get_u32() function just call strtoul(3) among a few sanity checks,
and the third parameter (value 16 here) is the base used to convert
the string. Here is a part of the manual page of strtoul(3) :

<< If base is zero or 16, the string may then include a `0x' prefix,n
   and the number will be read in base 16; otherwise, a zero base is
   taken as 10 (decimal) unless the next character is `0', in which
   case it is taken as 8 (octal). >>

As you can see, replacing 16 by 0 in this code would give the whole
Linux TCP/IP framework far more consistency, and will certainly avoid
numerous stupid mistakes. On the other hand, existing scripts that
(wrongly) rely on the fact that "10" means in fact "0x10", won't
work any longer and will need a little work for conversion.


Then, another lack I would like to point is that while iptable(8)
"mark" match allows to use a mask before comparing the packet mark
to the wanted value, ip(8) doesn't. It would be great to have this
feature. I think the patch is not difficult to write, although I'm
not a C guru, I could try to write it.


I'm waiting for your feedback. :)

Regards,
-- 
Jeremie LE HEN aka TtZ/TataZ
jeremie.le-hen@epita.fr . ttz@epita.fr
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

                 reply	other threads:[~2003-09-18 13:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=marc-lartc-106389287809097@msgid-missing \
    --to=le-hen_j@epita.fr \
    --cc=lartc@vger.kernel.org \
    /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