Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src



Hi again,

                port = ntohs(np->in_pmin) + ipf_random() %
                  (ntohs(np->in_pmax) - ntohs(np->in_pmin));

Ah, you are correct.  I should have looked closer.

Actually, no, it's not correct.  port is expected to be in network byte
order later on.  So I think the following diff should do it:

Index: ip_nat.c
===================================================================
RCS file: /cvsroot/src/sys/dist/ipf/netinet/ip_nat.c,v
retrieving revision 1.37
diff -u -r1.37 ip_nat.c
--- ip_nat.c    24 Jul 2008 09:37:58 -0000      1.37
+++ ip_nat.c    26 Jul 2008 12:34:19 -0000
@@ -2052,11 +2052,13 @@
                         * Standard port translation.  Select next port.
                         */
                        if (np->in_flags & IPN_SEQUENTIAL) {
-                               port = htons(np->in_pnext);
+                               port = np->in_pnext;
                        } else {
                                port = ipf_random() % (ntohs(np->in_pmax) -
-                                                      ntohs(np->in_pmin));
+                                                      ntohs(np->in_pmin))
+                                       + ntohs(np->in_pmin);
                        }
+                       port = htons(port);
                        np->in_pnext++;

                        if (np->in_pnext > ntohs(np->in_pmax)) {


Ciao,
Wolfgang
--
Wolfgang%Solfrank.net@localhost


Home | Main Index | Thread Index | Old Index