Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,35 @@
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
# IBM_PROLOG_END_TAG
SUBDIRS = kernext usr
EXPLIB_SUBDIRS = usr
SUBDIRS = usr/lib usr/sbin usr/lib/methods kernext

.include <$(RULES_MK)>
all: kernext/sys/socketvar.h kernext/sys/ioctl.h
touch kernext/sys/libsysp.h
for i in $(SUBDIRS); do \
(cd $$i && $(MAKE) $(MAKEFLAGS)); \
done

bff: all
mkdir -p usr/lib/drivers
cp kernext/ipf usr/lib/drivers/ipf
rm -rf .info
sed "s#<scriptdir>#`pwd`#g" ipfilter.tmpl >ipfilter.t
mkinstallp -d . -T ipfilter.t

clean:
rm -f kernext/sys/socketvar.h
for i in $(SUBDIRS); do \
(cd $$i && $(MAKE) $(MAKEFLAGS) clean); \
done
rm -f usr/lib/drivers/ipf
rmdir usr/lib/drivers || true
rm -f ipfilter.t
rm -rf .info

kernext/sys/socketvar.h: /usr/include/sys/socketvar.h
mkdir -p kernext/sys
sed "s#free_sock_hash_table\[\]#*free_sock_hash_table#g" $^ > $@

kernext/sys/ioctl.h: /usr/include/sys/ioctl.h
mkdir -p kernext/sys
sed "s#(0x40000000<<1)#(0x80000000)#" $^ | sed "s#((sizeof(t)\&IOCPARM_MASK)#(int)((sizeof(t)\&IOCPARM_MASK)#g" > $@
9 changes: 9 additions & 0 deletions ipfilter.rte.copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Copyright 2020 Cisco Systems, Inc. All rights reserved.
Copyright International Business Machines Corp. 2006, 2017.
Copyright Ryan Beasley, 2002-2003.
Copyright The Regents of the University of California, 1982-1983, 1986, 1988-1989, 1990-1997.
Copyright Digital Equipment Corporation, 1993.
Copyright Paul J. Ledbetter III, 2002-2003.
Copyright Darren Reed and Guido van Rooij, 1998-2003.
Copyright Darren Reed, 1993-2005.
Copyright RSA Data Security, Inc. 1990.
1 change: 1 addition & 0 deletions ipfilter.rte.post_i
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions ipfilter.rte.pre_i
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions ipfilter.rte.unpost_i
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

35 changes: 35 additions & 0 deletions ipfilter.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Package Name: ipfl
Package VRMF: 5.3.1.0
Update: N
Fileset
Fileset Name: ipfl.rte
Fileset VRMF: 5.3.1.0
Fileset Description: Ipfilter
Bosboot required: N
Copyright file path: <scriptdir>/ipfilter.rte.copyright
License agreement acceptance required: N
Include license files in this package: N
Requisites:
USRFiles
/usr/sbin/ipf
/usr/sbin/ipfs
/usr/sbin/ipfstat
/usr/sbin/ipnat
/usr/sbin/ippool
/usr/sbin/ipscan
/usr/sbin/ipmon
/usr/sbin/ipsyncm
/usr/sbin/ipsyncs
/usr/lib/methods/cfg_ipf
/usr/lib/drivers/ipf
EOUSRFiles
USRLIBLPPFiles
Pre-installation Script: <scriptdir>/ipfilter.rte.pre_i
Post-installation Script: <scriptdir>/ipfilter.rte.post_i
Unpost-installation Script: <scriptdir>/ipfilter.rte.unpost_i
EOUSRLIBLPPFiles
ROOT Part: N
ROOTFiles
EOROOTFiles
Relocatable: Y
EOFileset
60 changes: 30 additions & 30 deletions kernext/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,47 @@
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
# IBM_PROLOG_END_TAG
.include <${MAKETOP}bos/kernext/Kernext.mk>
MAKETOP=../..
INCFLAGS = -I${MAKETOP}/kernext -I${MAKETOP}/kernext/netinet -include strings.h
CC = gcc

VPATH = .:${MAKETOP}/bos/kernel/exp:${MAKETOP}/bos/kernext/inet
all: ipf

DUALMODE_KEXT = true
clean:
rm -f *.o ipf

KERNEL_EXT = ipf
KERNEL_EXT32 = ipf32
KERNEL_EXT64 = ipf64
KERNEXT_IMPORTS += sockets.exp kernex.exp netinet.exp statcmd.exp

IDIR = /usr/lib/drivers/
ILIST = ${KERNEL_EXT}
INCFLAGS = -I. -I./netinet -include strings.h
CFLAGS = -O2 -nostdlib -DAIX -D_AIX -D_AIX51 -DIPFILTER_LKM -DIPFILTER_LOG \
-DIPFILTER_LOOKUP -DIPFILTER_SCAN -DKERNEL -D_KERNEL -DINET ${INCFLAGS}
FIXRADIX = -Dradix_node=ipf_radix_node -Dradix_node_head=ipf_radix_node_head \
-Drn_inithead=ipf_rn_inithead -Drn_walktree=ipf_rn_walktree

LIBS = ${KERNEXT_LIBS}
fil.o: fil.c
${CC} -maix64 ${CFLAGS} -DIPF_DEFAULT_PASS=FR_PASS -c $< -o $@

ipf32_ENTRYPOINT = ipfconfig
ipf64_ENTRYPOINT = ipfconfig
ip_state.o: ip_state.c
${CC} -maix64 ${CFLAGS} -DIPSTATE_SIZE=249989 -DIPSTATE_MAX=1000000 -DIPSTATE_MAXBUCKET=256 -c $< -o $@

KERNEXT_IMPORTS += sockets.exp kernex.exp netinet.exp statcmd.exp
ip_pool.o: ip_pool.c
${CC} ${CFLAGS} ${FIXRADIX} -maix64 -c $< -o $@

INCFLAGS = -I./netinet
CFLAGS = -DAIX -D_AIX -D_AIX51 -DIPFILTER_LKM -DIPFILTER_LOG \
-DIPFILTER_LOOKUP -DIPFILTER_SCAN -DKERNEL -D_KERNEL -DINET
FIXRADIX = -Dradix_node=ipf_radix_node -Dradix_node_head=ipf_radix_node_head \
-Drn_inithead=ipf_rn_inithead -Drn_walktree=ipf_rn_walktree
ip_lookup.o: ip_lookup.c
${CC} ${CFLAGS} ${FIXRADIX} -maix64 -c $< -o $@

fil.o_CFLAGS = ${CFLAGS} -DIPF_DEFAULT_PASS=FR_PASS
ip_state.o_CFLAGS = ${CFLAGS} -DIPSTATE_SIZE=127
ip_pool.o_CFLAGS = ${CFLAGS} ${FIXRADIX}
ip_lookup.o_CFLAGS = ${CFLAGS} ${FIXRADIX}
radix.o: radix.c
${CC} ${CFLAGS} ${FIXRADIX} -maix64 -c $< -o $@

fil.64o_CFLAGS = ${CFLAGS} -DIPF_DEFAULT_PASS=FR_PASS
ip_state.64o_CFLAGS = ${CFLAGS} -DIPSTATE_SIZE=127
ip_pool.64o_CFLAGS = ${CFLAGS} ${FIXRADIX}
ip_lookup.64o_CFLAGS = ${CFLAGS} ${FIXRADIX}
ip_fil_aix.o: ip_fil_aix.c
${CC} ${CFLAGS} -maix64 -c $< -o $@

%.o: %.c
${CC} ${CFLAGS} -maix64 -c $< -o $@

OBJFILES = ip_fil_aix.o fil.o md5.o ip_nat.o ip_frag.o ip_state.o \
ip_proxy.o ip_auth.o ip_log.o ip_pool.o ip_htable.o \
ip_lookup.o ip_sync.o ip_scan.o ip_rules.o radix.o

ipf32_OFILES = ${OBJFILES}
ipf64_OFILES = ${OBJFILES:.o=.64o}
ip_lookup.o ip_sync.o ip_scan.o ip_rules.o radix.o log.o

.include <${RULES_MK}>
ipf: ${OBJFILES}
ld -b64 -o $@ $^ -bI:/usr/lib/kernex.exp -bI:/usr/lib/netinet.exp -bI:/usr/lib/sockets.exp -bI:/usr/lib/statcmd.exp -e ipfconfig -l csys -l sys
14 changes: 11 additions & 3 deletions kernext/fil.c
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,10 @@ fr_info_t *fin;
if (off != 0) {
fi->fi_flx |= FI_FRAG;
off &= IP_OFFMASK;
if (off != 0) {
//check if we have IP_MF bit set in offset, if yes then only,
//go to loop and validate it with given condition
// else that would be the last fragment and should not be validated
if ((off & ~IP_OFFMASK) != 0) {
fin->fin_flx |= FI_FRAGBODY;
off <<= 3;
if ((off + fin->fin_dlen > 65535) ||
Expand Down Expand Up @@ -3391,7 +3394,7 @@ minor_t unit;
int *nfreedp;
frentry_t **listp;
{
int freed = 0;
int freed = 0, i;
frentry_t *fp;

while ((fp = *listp) != NULL) {
Expand All @@ -3402,7 +3405,8 @@ frentry_t **listp;
}
*listp = fp->fr_next;
if (fp->fr_grp != NULL) {
(void) frflushlist(set, unit, nfreedp, fp->fr_grp);
i = frflushlist(set, unit, nfreedp, fp->fr_grp);
fp->fr_ref -= i;
}

if (fp->fr_grhead != NULL) {
Expand Down Expand Up @@ -4438,6 +4442,8 @@ caddr_t data;
(f->fr_isc != (struct ipscan *)-1))
ipsc_detachfr(f);
#endif
if ((fg != NULL) && (fg->fg_head != NULL))
fg->fg_head->fr_ref--;
if (unit == IPL_LOGAUTH) {
error = fr_preauthcmd(req, f, ftail);
goto done;
Expand Down Expand Up @@ -4476,6 +4482,8 @@ caddr_t data;
} else
f = fp;
if (f != NULL) {
if (fg != NULL && fg->fg_head != NULL)
fg->fg_head->fr_ref++;
if (fp != f)
bcopy((char *)fp, (char *)f,
sizeof(*f));
Expand Down
2 changes: 1 addition & 1 deletion kernext/ip_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct file;
# include "radix_ipf_local.h"
# define _RADIX_H_
#endif
#include <netinet/in.h>
#include <net/if.h>
#if defined(__FreeBSD__)
# include <sys/cdefs.h>
Expand All @@ -68,7 +69,6 @@ struct file;
# include <sys/mbuf.h>
# endif
#endif
#include <netinet/in.h>

#include "netinet/ip_compat.h"
#include "netinet/ip_fil.h"
Expand Down
2 changes: 1 addition & 1 deletion kernext/ip_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ struct file;
# include "radix_ipf_local.h"
# define _RADIX_H_
#endif
#include <net/if.h>
#include <netinet/in.h>
#include <net/if.h>
#if defined(_KERNEL) && defined(AIX)
# include <sys/mbuf.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion kernext/ip_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ int fr_statemax = IPSTATE_MAX,
fr_statesize = IPSTATE_SIZE;
int fr_state_doflush = 0,
fr_state_lock = 0,
fr_state_maxbucket = 0,
fr_state_maxbucket = IPSTATE_MAXBUCKET,
fr_state_maxbucket_reset = 1,
fr_state_init = 0;
ipftq_t ips_tqtqb[IPF_TCP_NSTATES],
Expand Down
22 changes: 22 additions & 0 deletions kernext/log.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <syslog.h>
#include <net/proto_uipc.h>
#include <stdio.h>
#include <stdarg.h>

int puts(const char *str)
{
bsdlog(LOG_DEBUG | LOG_KERN, "%.1000s\n",str);
}

int printf(const char *fmt, ...)
{
int rc;
char buf[1024];
va_list arg;
va_start(arg, fmt);

rc = vsnprintf_np(buf, 1024, fmt, arg);
rc = puts(buf);
va_end(arg);
return rc;
}
3 changes: 3 additions & 0 deletions kernext/netinet/ip_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ struct ipscan;
#ifndef IPSTATE_MAX
# define IPSTATE_MAX 4013 /* Maximum number of states held */
#endif
#ifndef IPSTATE_MAXBUCKET
# define IPSTATE_MAXBUCKET 0
#endif

#define PAIRS(s1,d1,s2,d2) ((((s1) == (s2)) && ((d1) == (d2))) ||\
(((s1) == (d2)) && ((d1) == (s2))))
Expand Down
4 changes: 1 addition & 3 deletions kernext/netinet/ipl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#ifndef __IPL_H__
#define __IPL_H__

#define IPL_VERSION "IP Filter: v4.1.13"

#define IPFILTER_VERSION 4011300
#define IPFILTER_VERSION 5030010

#endif
12 changes: 6 additions & 6 deletions kernext/radix.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ static char *rn_zeros = NULL, *rn_ones = NULL;
#undef Bcmp
#define Bcmp(a, b, l) (l == 0 ? 0 : bcmp((caddr_t)(a), (caddr_t)(b), (u_long)l))

static int rn_satisfies_leaf __P((char *, struct radix_node *, int));
static int rn_lexobetter __P((void *, void *));
static struct radix_mask *rn_new_radix_mask __P((struct radix_node *,
int rn_satisfies_leaf __P((char *, struct radix_node *, int));
int rn_lexobetter __P((void *, void *));
struct radix_mask *rn_new_radix_mask __P((struct radix_node *,
struct radix_mask *));
static int rn_freenode __P((struct radix_node *, void *));
#if defined(AIX) && !defined(_KERNEL)
Expand Down Expand Up @@ -247,7 +247,7 @@ rn_lookup(v_arg, m_arg, head)
return x;
}

static int
int
rn_satisfies_leaf(trial, leaf, skip)
char *trial;
struct radix_node *leaf;
Expand Down Expand Up @@ -561,7 +561,7 @@ rn_addmask(n_arg, search, skip)
return (x);
}

static int /* XXX: arbitrary ordering for non-contiguous masks */
int /* XXX: arbitrary ordering for non-contiguous masks */
rn_lexobetter(m_arg, n_arg)
void *m_arg, *n_arg;
{
Expand All @@ -576,7 +576,7 @@ rn_lexobetter(m_arg, n_arg)
return 0;
}

static struct radix_mask *
struct radix_mask *
rn_new_radix_mask(tt, next)
struct radix_node *tt;
struct radix_mask *next;
Expand Down
14 changes: 11 additions & 3 deletions usr/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ LIBRARIES = libipf.a
EXPLIB_TARGETS = export_libipf.a
EXPDIR = /usr/lib/ipfilter/

INCFLAGS = -I${MAKETOP}/ipfl/kernext -I${MAKETOP}/ipfl/kernext/netinet
CFLAGS = -D_AIX -D_AIX51 -DAIX -qlanglvl=ansi
MAKETOP=../..
INCFLAGS = -I${MAKETOP}/kernext -I${MAKETOP}/kernext/netinet -include strings.h
CC = gcc -maix64
AR = /usr/bin/ar
CFLAGS = -O2 -D_AIX -D_AIX51 -DAIX -D_NOGETDELIM ${INCFLAGS}

OFILES = addicmp.o addipopt.o bcopywrap.o \
binprint.o buildopts.o checkrev.o count6bits.o count4bits.o \
Expand All @@ -45,4 +48,9 @@ OFILES = addicmp.o addipopt.o bcopywrap.o \
to_interface.o var.o verbose.o v6ionames.o v6optvalue.o
OFILES64 = ${OFILES:.o=.64o}

.include <${RULES_MK}>
all: $(LIBRARIES)
clean:
rm -f *.o

$(LIBRARIES): $(OFILES)
$(AR) -Xany $(ARFLAGS) $@ $(OFILES)
2 changes: 2 additions & 0 deletions usr/lib/checkrev.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static char sccsid[] = "@(#)03 1.1 src/ipfl/usr/lib/checkrev.c, ipflt, 53ipfl5
int checkrev(ipfname)
char *ipfname;
{
#ifdef CHECK_IPL_VERSION
static int vfd = -1;
struct friostat fio, *fiop = &fio;
ipfobj_t ipfo;
Expand All @@ -57,5 +58,6 @@ char *ipfname;
if (strncmp(IPL_VERSION, fio.f_version, sizeof(fio.f_version))) {
return -1;
}
#endif
return 0;
}
Loading