tcpdump mailing list archives
pcap-bpf and AIX odm related code
From: "Jean-Louis CHARTON" <Jean-Louis.CHARTON () oikialog com>
Date: Thu, 8 Oct 2009 21:30:28 +0200
Hi, In the following piece of AIX specific code from pcap-bpf.c that creates and configures the /dev/bpf*; I think a call to bpf_odmcleanup is required in the cases where either genmajor() or genminor() fail (see "FIX HERE" below). Otherwise, the bpf_load() function returns without unlocking the ODM lock acquired in bpf_odminit(). static int bpf_load(char *errbuf) { long major; int *minors; int numminors, i, rc; char dummy_err[PCAP_ERRBUF_SIZE]; /* FIX HERE */ char buf[1024]; struct stat sbuf; struct bpf_config cfg_bpf; struct cfg_load cfg_ld; struct cfg_kmod cfg_km; /* * This is very very close to what happens in the real implementation * but I've fixed some (unlikely) bug situations. */ if (bpfloadedflag) return (0); if (bpf_odminit(errbuf) == PCAP_ERROR) return (PCAP_ERROR); major = genmajor(BPF_NAME); if (major == -1) { snprintf(errbuf, PCAP_ERRBUF_SIZE, "bpf_load: genmajor failed: %s", pcap_strerror(errno)); (void)bpf_odmcleanup(dummy_err); /* FIX HERE */ return (PCAP_ERROR); } minors = getminor(major, &numminors, BPF_NAME); if (!minors) { minors = genminor("bpf", major, 0, BPF_MINORS, 1, 1); if (!minors) { snprintf(errbuf, PCAP_ERRBUF_SIZE, "bpf_load: genminor failed: %s", pcap_strerror(errno)); (void)bpf_odmcleanup(dummy_err); /* FIX HERE */ return (PCAP_ERROR); } } ... Also, in function bpf_odminit(), I believe that a call to odm_terminate() is also needed in the case where odm_lock() fails. That is: ... if ((odmlockid = odm_lock("/etc/objrepos/config_lock", ODM_WAIT)) == -1) { if (odm_err_msg(odmerrno, &errstr) == -1) errstr = "Unknown error"; snprintf(errbuf, PCAP_ERRBUF_SIZE, "bpf_load: odm_lock of /etc/objrepos/config_lock failed: %s", errstr); (void)odm_terminate(); /* FIX HERE */ return (PCAP_ERROR); } ... Am I right? Hope this help. Best regards, J-L Charton - This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- pcap-bpf and AIX odm related code Jean-Louis CHARTON (Oct 08)
- Re: pcap-bpf and AIX odm related code Jean-Louis Charton (Oct 09)
- Re: pcap-bpf and AIX odm related code Guy Harris (Oct 09)
- Re: pcap-bpf and AIX odm related code Michael Richardson (Oct 09)
- Re: pcap-bpf and AIX odm related code Guy Harris (Oct 09)
- Re: pcap-bpf and AIX odm related code Randal T. Rioux (Oct 14)
- libpcap-1.0.0 on AIX 6.1 Randal T. Rioux (Oct 19)
- Re: libpcap-1.0.0 on AIX 6.1 Guy Harris (Oct 20)
- Re: libpcap-1.0.0 on AIX 6.1 Randal T. Rioux (Oct 20)
- Re: pcap-bpf and AIX odm related code Guy Harris (Oct 09)
- Re: pcap-bpf and AIX odm related code Jean-Louis Charton (Oct 09)
- Re: pcap-bpf and AIX odm related code Jean-Louis Charton (Oct 12)