NetBSD-Bugs archive

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

Re: bin/57767: blacklistd data inconsistency



The following reply was made to PR bin/57767; it has been noted by GNATS.

From: Yoshitaka Tokugawa <toku%tokugawa.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: Yoshitaka Tokugawa <toku%tokugawa.org@localhost>
Subject: Re: bin/57767: blacklistd data inconsistency
Date: Tue, 12 Dec 2023 08:37:35 +0900

 Sorry, My fix was incomplete.
 According to the dbopen man page, "the position of the cursor is not 
 affected by calls to the del, get, put, or sync routines.â??.
 
 However, if I put a record to the database in the middle of reading 
 records sequentially by (*seq)(), it seems to (*seq)() sometimes return 
 the same record. Why?
 
 I am not sure if my fix is the proper way, but if I open the database 
 with O_RDONLY and process the records, the "npfctl rule blacklistd show" 
 and "blacklistctl dump -b" information will remain consistent.
 
 *** blacklistd.c.orig   Mon Dec 11 11:57:04 2023
 --- blacklistd.c        Tue Dec 12 08:35:34 2023
 ***************
 *** 387,402 ****
    static void
    rules_restore(void)
    {
          struct conf c;
          struct dbinfo dbi;
          unsigned int f;
 
 !       for (f = 1; state_iterate(state, &c, &dbi, f) == 1; f = 0) {
                  if (dbi.id[0] == '\0')
                          continue;
 
                  (void)run_change("add", &c, dbi.id, sizeof(dbi.id));
          }
    }
 
    int
 --- 387,407 ----
    static void
    rules_restore(void)
    {
 +       DB *db; /* toku */
          struct conf c;
          struct dbinfo dbi;
          unsigned int f;
 
 !       db = state_open(dbfile, O_RDONLY, 0); /* toku */
 !       for (f = 1; state_iterate(db, &c, &dbi, f) == 1; f = 0) { /* toku */
                  if (dbi.id[0] == '\0')
                          continue;
 
                  (void)run_change("add", &c, dbi.id, sizeof(dbi.id));
 +               state_put(state, &c, &dbi); /* toku */
          }
 +       state_sync(state); /* toku */
 +       state_close(db); /* toku */
    }
 
    int
 
 On 2023/12/11 14:40, gnats-admin%netbsd.org@localhost wrote:
 > Thank you very much for your problem report.
 > It has the internal identification `bin/57767'.
 > The individual assigned to look at your
 > report is: bin-bug-people.
 >
 >> Category:       bin
 >> Responsible:    bin-bug-people
 >> Synopsis:       blacklistd data inconsistency
 >> Arrival-Date:   Mon Dec 11 05:40:00 +0000 2023
 



Home | Main Index | Thread Index | Old Index