Hello,

this is the third patch in the first PF radix changes batch.  Patch requires
earlier patches to be in place, otherwise compilation will fail.

Patch updates various user land tools by new PF radix table changes:
    s/DIOCRADDADDRS/DIOCRADDADDR
    s/DIOCRDELADDRS/DIOCRDELADDR   
it's also no longer possible to pass more than 1 IP address per ioctl(2) call.
Patch updates those tools:
    usr.sbin/authpf/authpf.c
    usr.sbin/bgpd/pftable.c
    usr.sbin/dhcpd/pfutils.c

thanks and
regards
sasha

--------8<---------------8<---------------8<------------------8<--------

Index: usr.sbin/authpf/authpf.c
===================================================================
RCS file: /cvs/src/usr.sbin/authpf/authpf.c,v
retrieving revision 1.123
diff -u -p -r1.123 authpf.c
--- usr.sbin/authpf/authpf.c    21 Jan 2015 21:50:32 -0000      1.123
+++ usr.sbin/authpf/authpf.c    27 Oct 2015 23:54:48 -0000
@@ -872,7 +872,7 @@ change_table(int add, const char *ipsrc)
                return (-1);
        }
 
-       if (ioctl(dev, add ? DIOCRADDADDRS : DIOCRDELADDRS, &io) &&
+       if (ioctl(dev, add ? DIOCRADDADDR : DIOCRDELADDR, &io) &&
            errno != ESRCH) {
                syslog(LOG_ERR, "cannot %s %s from table %s: %s",
                    add ? "add" : "remove", ipsrc, tablename,
Index: usr.sbin/bgpd/pftable.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/pftable.c,v
retrieving revision 1.8
diff -u -p -r1.8 pftable.c
--- usr.sbin/bgpd/pftable.c     21 Jan 2015 21:50:32 -0000      1.8
+++ usr.sbin/bgpd/pftable.c     27 Oct 2015 23:54:49 -0000
@@ -57,6 +57,8 @@ pftable_change(struct pf_table *pft)
 {
        struct pfioc_table tio;
        int ret;
+       int i;
+       struct pfr_addr *addr;
 
        if (pft->naddrs == 0 || pft->what == 0)
                return (0);
@@ -67,11 +69,15 @@ pftable_change(struct pf_table *pft)
        bzero(&tio, sizeof(tio));
        strlcpy(tio.pfrio_table.pfrt_name, pft->name,
            sizeof(tio.pfrio_table.pfrt_name));
-       tio.pfrio_buffer = pft->worklist;
        tio.pfrio_esize = sizeof(*pft->worklist);
-       tio.pfrio_size = pft->naddrs;
+       tio.pfrio_size = 1;
 
        ret = ioctl(devpf, pft->what, &tio);
+       addr = pft->worklist;
+       for (i = 0; (i < pft->naddrs) && (ret == 0); i++) {
+               tio.pfrio_buffer = addr++;
+               ret = ioctl(devpf, pft->what, &tio);
+       }
 
        /* bad prefixes shouldn't cause us to die */
        if (ret == -1) {
@@ -193,7 +199,7 @@ pftable_add_work(const char *table, stru
        }
 
        /* Only one type of work on the list at a time */
-       what = del ? DIOCRDELADDRS : DIOCRADDADDRS;
+       what = del ? DIOCRDELADDR : DIOCRADDADDR;
        if (pft->naddrs != 0 && pft->what != what)
                fatal("attempt to mix pf table additions/deletions");
 
Index: usr.sbin/dhcpd/pfutils.c
===================================================================
RCS file: /cvs/src/usr.sbin/dhcpd/pfutils.c,v
retrieving revision 1.13
diff -u -p -r1.13 pfutils.c
--- usr.sbin/dhcpd/pfutils.c    5 Feb 2015 09:42:52 -0000       1.13
+++ usr.sbin/dhcpd/pfutils.c    27 Oct 2015 23:54:51 -0000
@@ -154,7 +154,7 @@ pf_change_table(int fd, int op, struct i
        addr.pfra_af = AF_INET;
        addr.pfra_net = 32;
 
-       if (ioctl(fd, op ? DIOCRADDADDRS : DIOCRDELADDRS, &io) &&
+       if (ioctl(fd, op ? DIOCRADDADDR : DIOCRDELADDR, &io) &&
            errno != ESRCH) {
                warning( "DIOCR%sADDRS on table %s: %s",
                    op ? "ADD" : "DEL", table, strerror(errno));

Reply via email to