From e88b07c46727e8f8fb51223f0d7ec3c3942079b4 Mon Sep 17 00:00:00 2001
From: chantra <chantra@debuntu.org>
Date: Wed, 2 Jun 2010 14:00:36 +0200
Subject: [PATCH] Handle non standard subnets in PF grammar
Allow subnets for like 192.168.100.8/28 to be understood
Signed-off-by: chantra <chantra@debuntu.org>
---
pf.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/pf.c b/pf.c
index 3ce2ef2..f16ec9c 100644
a
|
b
|
add_subnet (const char *line, const char *prefix, const int line_num, struct pf_ |
121 | 121 | struct pf_subnet *e; |
122 | 122 | ALLOC_OBJ_CLEAR (e, struct pf_subnet); |
123 | 123 | e->rule.exclude = exclude; |
124 | | e->rule.network = ntohl (network.s_addr); |
| 124 | e->rule.network = ntohl (network.s_addr) & netmask; |
125 | 125 | e->rule.netmask = netmask; |
126 | 126 | **next = e; |
127 | 127 | *next = &e->next; |
--
1.5.6.5
From abe1ebc000cedac085d8f7ea7a8ff8a6b2947f8d Mon Sep 17 00:00:00 2001
From: chantra <chantra@debuntu.org>
Date: Wed, 2 Jun 2010 16:21:38 +0200
Subject: [PATCH] WARN on incorrect subnet
Log a warning when subnet is incorrect and is being converted
to a sane value
Signed-off-by: chantra <chantra@debuntu.org>
---
pf.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/pf.c b/pf.c
index f16ec9c..aed836e 100644
a
|
b
|
add_subnet (const char *line, const char *prefix, const int line_num, struct pf_ |
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | netmask = netbits_to_netmask (netbits); |
| 112 | if ((network.s_addr & htonl (netmask)) != network.s_addr) |
| 113 | { |
| 114 | network.s_addr &= htonl (netmask); |
| 115 | msg (M_WARN, "WARNING: PF: %s/%d: incorrect subnet %s/%d changed to %s/%d", prefix, line_num, line, netbits, inet_ntoa (network), netbits); |
| 116 | } |
112 | 117 | } |
113 | 118 | else |
114 | 119 | { |
… |
… |
add_subnet (const char *line, const char *prefix, const int line_num, struct pf_ |
121 | 126 | struct pf_subnet *e; |
122 | 127 | ALLOC_OBJ_CLEAR (e, struct pf_subnet); |
123 | 128 | e->rule.exclude = exclude; |
124 | | e->rule.network = ntohl (network.s_addr) & netmask; |
| 129 | e->rule.network = ntohl (network.s_addr); |
125 | 130 | e->rule.netmask = netmask; |
126 | 131 | **next = e; |
127 | 132 | *next = &e->next; |