diff options
author | Cedric Berger <cedric@cvs.openbsd.org> | 2003-07-31 22:25:56 +0000 |
---|---|---|
committer | Cedric Berger <cedric@cvs.openbsd.org> | 2003-07-31 22:25:56 +0000 |
commit | 71024192f8e6c068fce407d284f29caf19a22881 (patch) | |
tree | a0e5f6a9a8fa62cfce6cfea3891c42401256dfff /sbin | |
parent | 8deaa5cb1bdad9c4505896866607f4272b307e9a (diff) |
Make table tickets per-ruleset instead of global.
Make table tickets u_int32_t for consistency with other parts of PF.
Ok dhartmei@ henning@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/pfctl/pfctl.c | 15 | ||||
-rw-r--r-- | sbin/pfctl/pfctl.h | 6 | ||||
-rw-r--r-- | sbin/pfctl/pfctl_parser.h | 6 | ||||
-rw-r--r-- | sbin/pfctl/pfctl_radix.c | 11 | ||||
-rw-r--r-- | sbin/pfctl/pfctl_table.c | 4 |
5 files changed, 27 insertions, 15 deletions
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index c9e35ec956a..15eb3840683 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl.c,v 1.182 2003/07/18 06:30:07 cedric Exp $ */ +/* $OpenBSD: pfctl.c,v 1.183 2003/07/31 22:25:54 cedric Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -921,15 +921,22 @@ pfctl_rules(int dev, char *filename, int opts, char *anchorname, struct pfioc_rule pr[PF_RULESET_MAX]; struct pfioc_altq pa; struct pfctl pf; + struct pfr_table trs; int i; memset(&pa, 0, sizeof(pa)); memset(&pf, 0, sizeof(pf)); + memset(&trs, 0, sizeof(trs)); for (i = 0; i < PF_RULESET_MAX; i++) { memset(&pr[i], 0, sizeof(pr[i])); memcpy(pr[i].anchor, anchorname, sizeof(pr[i].anchor)); memcpy(pr[i].ruleset, rulesetname, sizeof(pr[i].ruleset)); } + if (strlcpy(trs.pfrt_anchor, anchorname, + sizeof(trs.pfrt_anchor)) >= sizeof(trs.pfrt_anchor) || + strlcpy(trs.pfrt_ruleset, rulesetname, + sizeof(trs.pfrt_ruleset)) >= sizeof(trs.pfrt_ruleset)) + ERRX("pfctl_rules: strlcpy"); if (strcmp(filename, "-") == 0) { fin = stdin; infile = "stdin"; @@ -965,7 +972,7 @@ pfctl_rules(int dev, char *filename, int opts, char *anchorname, ERR("DIOCBEGINRULES"); } if (loadopt & PFCTL_FLAG_TABLE) { - if (pfr_ina_begin(&pf.tticket, NULL, 0) != 0) + if (pfr_ina_begin(&trs, &pf.tticket, NULL, 0) != 0) ERR("begin table"); } } @@ -1014,7 +1021,7 @@ pfctl_rules(int dev, char *filename, int opts, char *anchorname, ERR("DIOCCOMMITRULES FILTER"); } if (loadopt & PFCTL_FLAG_TABLE) { - if (pfr_ina_commit(pf.tticket, NULL, NULL, 0)) + if (pfr_ina_commit(&trs, pf.tticket, NULL, NULL, 0)) ERR("commit table"); pf.tdirty = 0; } @@ -1031,7 +1038,7 @@ pfctl_rules(int dev, char *filename, int opts, char *anchorname, _error: if (pf.tdirty) /* cleanup kernel leftover */ - pfr_ina_begin(NULL, NULL, 0); + pfr_ina_begin(&trs, NULL, NULL, 0); exit(1); #undef ERR diff --git a/sbin/pfctl/pfctl.h b/sbin/pfctl/pfctl.h index ad6e0b85aec..750f80167c8 100644 --- a/sbin/pfctl/pfctl.h +++ b/sbin/pfctl/pfctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl.h,v 1.23 2003/07/04 11:05:44 henning Exp $ */ +/* $OpenBSD: pfctl.h,v 1.24 2003/07/31 22:25:54 cedric Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -63,8 +63,8 @@ int pfr_get_astats(struct pfr_table *, struct pfr_astats *, int *, int); int pfr_clr_astats(struct pfr_table *, struct pfr_addr *, int, int *, int); int pfr_tst_addrs(struct pfr_table *, struct pfr_addr *, int, int *, int); int pfr_set_tflags(struct pfr_table *, int, int, int, int *, int *, int); -int pfr_ina_begin(int *, int *, int); -int pfr_ina_commit(int, int *, int *, int); +int pfr_ina_begin(struct pfr_table *, int *, int *, int); +int pfr_ina_commit(struct pfr_table *, int, int *, int *, int); int pfr_ina_define(struct pfr_table *, struct pfr_addr *, int, int *, int *, int, int); void pfr_buf_clear(struct pfr_buffer *); diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h index 1079d5925c4..b8331a5b725 100644 --- a/sbin/pfctl/pfctl_parser.h +++ b/sbin/pfctl/pfctl_parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_parser.h,v 1.65 2003/07/18 06:30:07 cedric Exp $ */ +/* $OpenBSD: pfctl_parser.h,v 1.66 2003/07/31 22:25:54 cedric Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -60,7 +60,7 @@ struct pfctl { int dev; int opts; int loadopt; - int tticket; /* table ticket */ + u_int32_t tticket; /* table ticket */ int tdirty; /* kernel dirty */ u_int32_t rule_nr; struct pfioc_pooladdr paddr; @@ -166,7 +166,7 @@ void print_queue(const struct pf_altq *, unsigned, struct node_queue_bw *, int, struct node_queue_opt *); int pfctl_define_table(char *, int, int, const char *, const char *, - struct pfr_buffer *, int); + struct pfr_buffer *, u_int32_t); struct icmptypeent { const char *name; diff --git a/sbin/pfctl/pfctl_radix.c b/sbin/pfctl/pfctl_radix.c index 1ff36e3e643..a07285f49fd 100644 --- a/sbin/pfctl/pfctl_radix.c +++ b/sbin/pfctl/pfctl_radix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_radix.c,v 1.18 2003/07/04 11:05:44 henning Exp $ */ +/* $OpenBSD: pfctl_radix.c,v 1.19 2003/07/31 22:25:54 cedric Exp $ */ /* * Copyright (c) 2002 Cedric Berger @@ -391,11 +391,13 @@ pfr_tst_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size, } int -pfr_ina_begin(int *ticket, int *ndel, int flags) +pfr_ina_begin(struct pfr_table *trs, int *ticket, int *ndel, int flags) { struct pfioc_table io; bzero(&io, sizeof io); + if (trs != NULL) + io.pfrio_table = *trs; io.pfrio_flags = flags; if (ioctl(dev, DIOCRINABEGIN, &io)) return (-1); @@ -407,11 +409,14 @@ pfr_ina_begin(int *ticket, int *ndel, int flags) } int -pfr_ina_commit(int ticket, int *nadd, int *nchange, int flags) +pfr_ina_commit(struct pfr_table *trs, int ticket, int *nadd, int *nchange, + int flags) { struct pfioc_table io; bzero(&io, sizeof io); + if (trs != NULL) + io.pfrio_table = *trs; io.pfrio_flags = flags; io.pfrio_ticket = ticket; if (ioctl(dev, DIOCRINACOMMIT, &io)) diff --git a/sbin/pfctl/pfctl_table.c b/sbin/pfctl/pfctl_table.c index c0500379872..01af4423eef 100644 --- a/sbin/pfctl/pfctl_table.c +++ b/sbin/pfctl/pfctl_table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_table.c,v 1.48 2003/07/11 08:29:34 cedric Exp $ */ +/* $OpenBSD: pfctl_table.c,v 1.49 2003/07/31 22:25:54 cedric Exp $ */ /* * Copyright (c) 2002 Cedric Berger @@ -443,7 +443,7 @@ radix_perror(void) int pfctl_define_table(char *name, int flags, int addrs, const char *anchor, - const char *ruleset, struct pfr_buffer *ab, int ticket) + const char *ruleset, struct pfr_buffer *ab, u_int32_t ticket) { struct pfr_table tbl; |