Re: Journal Implementation
http://www.openbsd.org/faq/faq8.html#Journaling On Tue, Jun 2, 2015, 2:31 PM Walter Neto wsouz...@gmail.com wrote: Hy.. I want to help OpenBSD developing a journaling system for UFS. Someone can give me a tip? Thanks.
Journal Implementation
Hy.. I want to help OpenBSD developing a journaling system for UFS. Someone can give me a tip? Thanks.
Re: Journal Implementation
Just to save time in case soft updates would serve Walter's interests just as well as journaling. No, I can't rest assured that anybody is aware of anything, no offense to Paul or Walter. FreeBSD's gjournal might help... http://lists.freebsd.org/pipermail/freebsd-current/2006-June/064043.html On Tue, Jun 2, 2015, 4:03 PM Paul de Weerd we...@weirdnet.nl wrote: On Tue, Jun 02, 2015 at 07:33:58PM +, Stefan wrote: | http://www.openbsd.org/faq/faq8.html#Journaling Right, that doesn't help, it's not a tip for someone interested in *developing a journaling system for UFS*... You can rest assured they're already aware that OpenBSD doesn't support journaling. | On Tue, Jun 2, 2015, 2:31 PM Walter Neto wsouz...@gmail.com wrote: | Hy.. | | I want to help OpenBSD developing a journaling system for UFS. | | Someone can give me a tip? Please have a look at this implementation from the FFS author: http://www.mckusick.com/softdep/suj.pdf I believe the code is available in FreeBSD. All it takes is porting. Before you start your work, keep in mind that there's no guarantee that it will be incorporated in OpenBSD. But, if you present your case with proper diffs, you should at least get some attention. Good luck! Paul 'WEiRD' de Weerd -- [++-]+++.+++[---].+++[+ +++-].++[-]+.--.[-] http://www.weirdnet.nl/
Re: Journal Implementation
On Tue, Jun 02, 2015 at 07:33:58PM +, Stefan wrote: | http://www.openbsd.org/faq/faq8.html#Journaling Right, that doesn't help, it's not a tip for someone interested in *developing a journaling system for UFS*... You can rest assured they're already aware that OpenBSD doesn't support journaling. | On Tue, Jun 2, 2015, 2:31 PM Walter Neto wsouz...@gmail.com wrote: | Hy.. | | I want to help OpenBSD developing a journaling system for UFS. | | Someone can give me a tip? Please have a look at this implementation from the FFS author: http://www.mckusick.com/softdep/suj.pdf I believe the code is available in FreeBSD. All it takes is porting. Before you start your work, keep in mind that there's no guarantee that it will be incorporated in OpenBSD. But, if you present your case with proper diffs, you should at least get some attention. Good luck! Paul 'WEiRD' de Weerd -- [++-]+++.+++[---].+++[+ +++-].++[-]+.--.[-] http://www.weirdnet.nl/
Re: Journal Implementation
Thanks guys.. I will read all the tips, and start to code.. Once I have a diff I share.. On Jun 2, 2015, at 9:06 PM, Walter Neto wsouz...@gmail.com wrote: On Jun 2, 2015, at 5:03 PM, Paul de Weerd we...@weirdnet.nl wrote: On Tue, Jun 02, 2015 at 07:33:58PM +, Stefan wrote: | http://www.openbsd.org/faq/faq8.html#Journaling Right, that doesn't help, it's not a tip for someone interested in *developing a journaling system for UFS*... You can rest assured they're already aware that OpenBSD doesn't support journaling. | On Tue, Jun 2, 2015, 2:31 PM Walter Neto wsouz...@gmail.com wrote: | Hy.. | | I want to help OpenBSD developing a journaling system for UFS. | | Someone can give me a tip? Please have a look at this implementation from the FFS author: http://www.mckusick.com/softdep/suj.pdf I believe the code is available in FreeBSD. All it takes is porting. Before you start your work, keep in mind that there's no guarantee that it will be incorporated in OpenBSD. But, if you present your case with proper diffs, you should at least get some attention. Thank you Paul! I intend to help the OpenBSD project, cause is the OS wich I like best, and the feature is the one I need now. So, I will do my best! Good luck! Paul 'WEiRD' de Weerd -- [++-]+++.+++[---].+++[+ +++-].++[-]+.--.[-] http://www.weirdnet.nl/
Re: Journal Implementation
On Jun 2, 2015, at 5:03 PM, Paul de Weerd we...@weirdnet.nl wrote: On Tue, Jun 02, 2015 at 07:33:58PM +, Stefan wrote: | http://www.openbsd.org/faq/faq8.html#Journaling Right, that doesn't help, it's not a tip for someone interested in *developing a journaling system for UFS*... You can rest assured they're already aware that OpenBSD doesn't support journaling. | On Tue, Jun 2, 2015, 2:31 PM Walter Neto wsouz...@gmail.com wrote: | Hy.. | | I want to help OpenBSD developing a journaling system for UFS. | | Someone can give me a tip? Please have a look at this implementation from the FFS author: http://www.mckusick.com/softdep/suj.pdf I believe the code is available in FreeBSD. All it takes is porting. Before you start your work, keep in mind that there's no guarantee that it will be incorporated in OpenBSD. But, if you present your case with proper diffs, you should at least get some attention. Thank you Paul! I intend to help the OpenBSD project, cause is the OS wich I like best, and the feature is the one I need now. So, I will do my best! Good luck! Paul 'WEiRD' de Weerd -- [++-]+++.+++[---].+++[+ +++-].++[-]+.--.[-] http://www.weirdnet.nl/
Re: Journal Implementation
On Tue, Jun 02, 2015 at 09:57:01PM BST, Stefan wrote: FreeBSD's gjournal might help... http://lists.freebsd.org/pipermail/freebsd-current/2006-June/064043.html While you're at it, this[0] might also be of interest. [0] http://netbsd.gw.com/cgi-bin/man-cgi?wapbl Raf
Re: Journal Implementation
Maybe help port hammer? https://www.google-melange.com/gsoc/project/details/google/gsoc2015/jorisgio/5713964361056256 On Tue, Jun 2, 2015 at 4:21 PM, Raf Czlonka rczlo...@gmail.com wrote: On Tue, Jun 02, 2015 at 09:57:01PM BST, Stefan wrote: FreeBSD's gjournal might help... http://lists.freebsd.org/pipermail/freebsd-current/2006-June/064043.html While you're at it, this[0] might also be of interest. [0] http://netbsd.gw.com/cgi-bin/man-cgi?wapbl Raf
Mg: remove unused defines and functions
Hi tech@ -- The diff below removes unused defines and functions in mg. I went through everything in def.h one by one, so hopefully this removes everything unused. OK? ~Brian Index: def.h === RCS file: /cvs/src/usr.bin/mg/def.h,v retrieving revision 1.146 diff -u -p -r1.146 def.h --- def.h 8 May 2015 12:35:08 - 1.146 +++ def.h 3 Jun 2015 02:57:05 - @@ -21,13 +21,13 @@ typedef int (*PF)(int, int);/* generall #define NBUFN NFILEN /* Length, buffer name. */ #define NLINE 256 /* Length, line. */ #define PBMODES 4 /* modes per buffer */ -#define NKBDM 256 /* Length, keyboard macro. */ #define NPAT 80 /* Length, pattern. */ #define HUGE 1000/* A rather large number.*/ #define NSRCH 128 /* Undoable search commands. */ #define NXNAME 64 /* Length, extended command. */ #define NKNAME 20 /* Length, key names.*/ #define NTIME 50 /* Length, timestamp string. */ + /* * Universal. */ @@ -61,13 +61,6 @@ typedef int (*PF)(int, int);/* generall #define FIODIR 5 /* File is a directory */ /* - * Directory I/O. - */ -#define DIOSUC 0 /* Success. */ -#define DIOEOF 1 /* End of file. */ -#define DIOERR 2 /* Error.*/ - -/* * Display colors. */ #define CNONE 0 /* Unknown color.*/ @@ -388,7 +381,6 @@ struct line *lalloc(int); int lrealloc(struct line *, int); voidlfree(struct line *); voidlchange(int); -int linsert_str(const char *, int); int linsert(int, int); int lnewline_at(struct line *, int); int lnewline(void); @@ -408,7 +400,6 @@ int yank(int, int); /* window.c X */ struct mgwin *new_window(struct buffer *); -voidfree_window(struct mgwin *); int reposition(int, int); int redraw(int, int); int do_redraw(int, int, int); @@ -654,7 +645,6 @@ int executemacro(int, int); /* modes.c X */ int indentmode(int, int); int fillmode(int, int); -int blinkparen(int, int); #ifdef NOTAB int notabmode(int, int); #endif /* NOTAB */ Index: line.c === RCS file: /cvs/src/usr.bin/mg/line.c,v retrieving revision 1.55 diff -u -p -r1.55 line.c --- line.c 19 Mar 2015 21:22:15 - 1.55 +++ line.c 3 Jun 2015 02:57:05 - @@ -131,100 +131,6 @@ lchange(int flag) } /* - * Insert n bytes from s at the current location of dot. - * In the easy case all that happens is the text is stored in the line. - * In the hard case, the line has to be reallocated. When the window list - * is updated, take special care; I screwed it up once. You always update - * dot in the current window. You update mark and a dot in another window - * if it is greater than the place where you did the insert. Return TRUE - * if all is well, and FALSE on errors. - */ -int -linsert_str(const char *s, int n) -{ - struct line *lp1; - struct mgwin*wp; - RSIZEi; - int doto, k; - - if ((k = checkdirty(curbp)) != TRUE) - return (k); - - if (curbp-b_flag BFREADONLY) { - dobeep(); - ewprintf(Buffer is read only); - return (FALSE); - } - - if (!n) - return (TRUE); - - lchange(WFFULL); - - /* current line */ - lp1 = curwp-w_dotp; - - /* special case for the end */ - if (lp1 == curbp-b_headp) { - struct line *lp2, *lp3; - - /* now should only happen in empty buffer */ - if (curwp-w_doto != 0) - panic(bug: linsert_str); - /* allocate a new line */ - if ((lp2 = lalloc(n)) == NULL) - return (FALSE); - /* previous line */ - lp3 = lp1-l_bp; - /* link in */ - lp3-l_fp = lp2; - lp2-l_fp = lp1; - lp1-l_bp = lp2; - lp2-l_bp = lp3; - for (i = 0; i n; ++i) - lp2-l_text[i] = s[i]; - for (wp = wheadp; wp != NULL; wp = wp-w_wndp) { - if (wp-w_linep == lp1) - wp-w_linep = lp2; - if (wp-w_dotp == lp1) - wp-w_dotp = lp2; - if (wp-w_markp == lp1) - wp-w_markp = lp2; - } - undo_add_insert(lp2, 0, n); -
Simple upd(4) sensors
Here are some new sensors for upd(4) devices. All exist on my device except AtRateTimeToEmpty, which still seemed a logical addition given that AtRateTimeToFull is already present. - AtRateTimeToEmpty - RunTimeToEmpty - NeedReplacement - Overload If anyone had an AtRate sensor, it was probably producing meaningless output. The relevant spec [0] indicates that these are in minutes, and my device appears to be using seconds; the (previously unscaled) sensor value expects nanoseconds! [0] http://www.usb.org/developers/hidpage/pdcv10.pdf And lastly, the NeedReplacement report has nothing to do with the System Management Bus (SMB), so rename the constant. Nothing else in the tree appears to use it, so hopefully this is safe. Feedback and lsusb -v output is welcome, as usual. --david --- a/upd.c +++ b/upd.c @@ -66,7 +66,13 @@ static struct upd_usage_entry upd_usage_ { HUP_BATTERY, HUB_DISCHARGING, SENSOR_INDICATOR,Discharging }, { HUP_BATTERY, HUB_ATRATE_TIMETOFULL, - SENSOR_TIMEDELTA,AtRateTimeToFull } + SENSOR_TIMEDELTA,AtRateTimeToFull }, + { HUP_BATTERY, HUB_ATRATE_TIMETOEMPTY, + SENSOR_TIMEDELTA,AtRateTimeToEmpty }, + { HUP_BATTERY, HUB_RUNTIMETO_EMPTY, + SENSOR_TIMEDELTA,RunTimeToEmpty }, + { HUP_BATTERY, HUB_NEED_REPLACEMENT, + SENSOR_INDICATOR,NeedReplacement }, }; static struct upd_usage_entry upd_usage_roots[] = { { HUP_BATTERY, HUB_BATTERY_PRESENT, @@ -75,7 +81,9 @@ static struct upd_usage_entry upd_usage_ { HUP_POWER,HUP_SHUTDOWN_IMMINENT, SENSOR_INDICATOR,ShutdownImminent }, { HUP_BATTERY, HUB_AC_PRESENT, - SENSOR_INDICATOR,ACPresent } + SENSOR_INDICATOR,ACPresent }, + { HUP_POWER,HUP_OVERLOAD, + SENSOR_INDICATOR,Overload }, }; #define UPD_MAX_SENSORS(nitems(upd_usage_batdep) + nitems(upd_usage_roots)) @@ -410,6 +418,12 @@ upd_sensor_update(struct upd_softc *sc, case HUB_FULLCHARGE_CAPACITY: adjust = 1000; /* scale adjust */ break; + case HUB_ATRATE_TIMETOFULL: + case HUB_ATRATE_TIMETOEMPTY: + case HUB_RUNTIMETO_EMPTY: + /* spec says minutes, not seconds */ + adjust = 10LL; + break; default: adjust = 1; /* no scale adjust */ break; --- a/usbhid.h +++ b/usbhid.h @@ -213,7 +213,7 @@ struct usb_hid_descriptor { #define HUB_CONDITIONING_FLAG 0x0048 #define HUB_ATRATE_OK 0x0049 #define HUB_SMB_ERROR_CODE 0x004a -#define HUB_SMB_NEED_REPLACE 0x004b +#define HUB_NEED_REPLACEMENT 0x004b #define HUB_ATRATE_TIMETOFULL 0x0060 #define HUB_ATRATE_TIMETOEMPTY 0x0061 #define HUB_AVERAGE_CURRENT0x0062
Re: Thread-safe libcrypto by using weak symbols to pthread
On Sun, Mar 29, 2015 at 4:51 AM, Carlos MartÃn Nieto c...@dwim.me wrote: On Sat, Mar 28, 2015 at 09:59:57PM -0700, Philip Guenther wrote: On Sat, 28 Mar 2015, Carlos Mart?n Nieto wrote: I?ve been looking into making libcrypto automatically thread-safe. The obvious solution is to use pthread to perform the locking instead of relying on the user to set locking callbacks, as the final user shouldn?t need to care that LibreSSL is involved in the dependencies at some level. Well. How far is our reach on this? Solving this just for LibreSSL on OpenBSD? I guess you diff works, though it doesn't work when libpthread can be loaded after startup as the bindings won't be updated. If the goal is just this, then application writers in the wider software ecosystem won't even notice and will have to continue to use the callbacks, etc. Fixing this in LibreSSL (even if on all supported OSs) rather than in OpenSSL certainly gives this less reach, but as LibreSSL is a lot more focused on what it wants to support, it makes the implementation for this much less problematic. Today in LibreSSL portable, we already either link -lpthread, or the target OS has some sort of mutex support already factored into the C library directly. I'd be in favor of just always having the mutexes enabled. We're already unconditionally enabling mutexes in arc4random - this is not much of a stretch. I think it makes sense to make some parts of libtls independently threadsafe too, such as tls_init.
Re: Journal Implementation
Hi, On Jun 3, 2015 3:17 AM, Walter Neto wsouz...@gmail.com wrote: Thanks guys.. I will read all the tips, and start to code.. Once I have a diff I share.. On Jun 2, 2015, at 9:06 PM, Walter Neto wsouz...@gmail.com wrote: On Jun 2, 2015, at 5:03 PM, Paul de Weerd we...@weirdnet.nl wrote: On Tue, Jun 02, 2015 at 07:33:58PM +, Stefan wrote: | http://www.openbsd.org/faq/faq8.html#Journaling Right, that doesn't help, it's not a tip for someone interested in *developing a journaling system for UFS*... You can rest assured they're already aware that OpenBSD doesn't support journaling. | On Tue, Jun 2, 2015, 2:31 PM Walter Neto wsouz...@gmail.com wrote: | Hy.. | | I want to help OpenBSD developing a journaling system for UFS. | | Someone can give me a tip? Please have a look at this implementation from the FFS author: http://www.mckusick.com/softdep/suj.pdf I believe the code is available in FreeBSD. All it takes is porting. Before you start your work, keep in mind that there's no guarantee that it will be incorporated in OpenBSD. But, if you present your case with proper diffs, you should at least get some attention. Thank you Paul! I intend to help the OpenBSD project, cause is the OS wich I like best, and the feature is the one I need now. So, I will do my best! Good luck! Paul 'WEiRD' de Weerd -- [++-]+++.+++[---].+++[+ +++-].++[-]+.--.[-] http://www.weirdnet.nl/ have a look on Bitrig, they have implemented NetBSD's journaling and is an OpenBSD fork. -- Regards, Ville
Re: [Patch] httpd - don't leak fcgi file descriptors
Am 01.06.2015 um 01:25 schrieb Todd Mortimer t...@opennet.ca: I agree that my patch is more of a workaround, and it would be better to track down how it is that the client is being passed to server_fcgi with an open socket. I was going this way when I started looking at the source, but then I saw that clt-clt_srvevb and clt-clt_srvbev get the same treatment (free if not null, then reassign) at the same spot in server_fcgi(), and I figured if it was good enough for clt_srvevb and clt_srvbev, why not for clt_fd? Yes, you are right. I think your proposed diff is correct. I would like to commit it, if anyone is willing to give OK. Thanks, Regards, Joerg Index: server_fcgi.c === RCS file: /cvs/src/usr.sbin/httpd/server_fcgi.c,v retrieving revision 1.53 diff -u -p -u -p -r1.53 server_fcgi.c --- server_fcgi.c26 Mar 2015 09:01:51 -1.53 +++ server_fcgi.c31 May 2015 22:33:54 - @@ -31,6 +31,7 @@ #include stdio.h #include time.h #include ctype.h +#include unistd.h #include event.h #include httpd.h @@ -152,6 +153,9 @@ server_fcgi(struct httpd *env, struct cl errstr = failed to allocate evbuffer; goto fail; } + +if(clt-clt_fd != -1) +close(clt-clt_fd); clt-clt_fd = fd; if (clt-clt_srvbev != NULL)
arp(8) and ndp(8) fixes
In order to support multiple connected routes using MPATH, we no longer put an empty link-layer sockaddr in the 'gateway' field of such routes. This made arp(8) and ndp(8) unhappy because they both assumed that the 'gateway' socakddr contains an interface index. Diff below should make them behave as before be explicitly requesting the RTA_IFP sockaddr, just like route(8) and dhclient(8) do. Ok? Index: arp/arp.c === RCS file: /cvs/src/usr.sbin/arp/arp.c,v retrieving revision 1.63 diff -u -p -r1.63 arp.c --- arp/arp.c 16 Jan 2015 06:40:15 - 1.63 +++ arp/arp.c 1 Jun 2015 10:27:47 - @@ -75,6 +75,7 @@ int file(char *); int get(const char *); int getinetaddr(const char *, struct in_addr *); void getsocket(void); +int rtget(struct sockaddr_inarp **, struct sockaddr_dl **); int rtmsg(int); int set(int, char **); void usage(void); @@ -254,6 +255,7 @@ getsocket(void) struct sockaddr_in so_mask = { 8, 0, 0, { 0x } }; struct sockaddr_inarp blank_sin = { sizeof(blank_sin), AF_INET }, sin_m; struct sockaddr_dl blank_sdl = { sizeof(blank_sdl), AF_LINK }, sdl_m; +struct sockaddr_dl ifp_m = { sizeof(ifp_m), AF_LINK }; time_t expire_time; intflags, export_only, doing_proxy, found_entry; struct { @@ -319,12 +321,11 @@ set(int argc, char *argv[]) } tryagain: - if (rtmsg(RTM_GET) 0) { + if (rtget(sin, sdl)) { warn(%s, host); return (1); } - sin = (struct sockaddr_inarp *)((char *)rtm + rtm-rtm_hdrlen); - sdl = (struct sockaddr_dl *)(ROUNDUP(sin-sin_len) + (char *)sin); + if (sin-sin_addr.s_addr == sin_m.sin_addr.s_addr) { if (sdl-sdl_family == AF_LINK (rtm-rtm_flags RTF_LLINFO) @@ -412,15 +413,13 @@ delete(const char *host, const char *inf if (getinetaddr(host, sin-sin_addr) == -1) return (1); tryagain: - if (rtmsg(RTM_GET) 0) { + if (rtget(sin, sdl) 0) { warn(%s, host); return (1); } - sin = (struct sockaddr_inarp *)((char *)rtm + rtm-rtm_hdrlen); - sdl = (struct sockaddr_dl *)(ROUNDUP(sin-sin_len) + (char *)sin); if (sin-sin_addr.s_addr == sin_m.sin_addr.s_addr) { if (sdl-sdl_family == AF_LINK rtm-rtm_flags RTF_LLINFO) { - if (rtm-rtm_flags (RTF_LOCAL|RTF_BROADCAST)) + if (rtm-rtm_flags RTF_LOCAL) return (0); if (!(rtm-rtm_flags RTF_GATEWAY)) switch (sdl-sdl_type) { @@ -493,8 +492,6 @@ search(in_addr_t addr, void (*action)(st rtm = (struct rt_msghdr *)next; if (rtm-rtm_version != RTM_VERSION) continue; - if (rtm-rtm_flags RTF_BROADCAST) - continue; sin = (struct sockaddr_inarp *)(next + rtm-rtm_hdrlen); sdl = (struct sockaddr_dl *)(sin + 1); if (addr) { @@ -558,7 +555,7 @@ print_entry(struct sockaddr_dl *sdl, str printf(%-*.*s %-*.*s %*.*s, addrwidth, addrwidth, host, llwidth, llwidth, ether_str(sdl), ifwidth, ifwidth, ifname); - if (rtm-rtm_flags (RTF_PERMANENT_ARP|RTF_LOCAL|RTF_BROADCAST)) + if (rtm-rtm_flags (RTF_PERMANENT_ARP|RTF_LOCAL)) printf( %-10.10s, permanent); else if (rtm-rtm_rmx.rmx_expire == 0) printf( %-10.10s, static); @@ -654,7 +651,7 @@ rtmsg(int cmd) } /* FALLTHROUGH */ case RTM_GET: - rtm-rtm_addrs |= RTA_DST; + rtm-rtm_addrs |= (RTA_DST | RTA_IFP); } #define NEXTADDR(w, s) \ @@ -666,6 +663,7 @@ rtmsg(int cmd) NEXTADDR(RTA_DST, sin_m); NEXTADDR(RTA_GATEWAY, sdl_m); NEXTADDR(RTA_NETMASK, so_mask); + NEXTADDR(RTA_IFP, ifp_m); rtm-rtm_msglen = cp - (char *)m_rtmsg; doit: @@ -685,6 +683,48 @@ doit: if (l 0) warn(read from routing socket); + return (0); +} + +int +rtget(struct sockaddr_inarp **sinp, struct sockaddr_dl **sdlp) +{ + struct rt_msghdr *rtm = (m_rtmsg.m_rtm); + struct sockaddr_inarp *sin = NULL; + struct sockaddr_dl *sdl = NULL; + struct sockaddr *sa; + char *cp; + int i; + + if (rtmsg(RTM_GET) 0) + return (1); + + if (rtm-rtm_addrs) { + cp = ((char *)rtm + rtm-rtm_hdrlen); + for (i = 1; i; i = 1) { + if (i rtm-rtm_addrs) { + sa = (struct sockaddr *)cp; + switch (i) { + case RTA_DST: + sin = (struct sockaddr_inarp *)sa; +
No #if NCARP in Ethernet layer
This diff is a cleanup needed for upcoming bridge(4) changes but has two nice side effects on its own. By moving the Ethernet header rewrite logic into carp_start(), it is now possible to tcpdump(8) output packets on a carp(4) interface and we get rid of the #if NCARP 0 in ether_output(). Moving such logic into carp_start() is the best solution I came with. It works with all our pseudo-drivers in a unified way, will allow me to fix some bridge(4) bugs and does not require a complex change in the network stack like if_input(). Ok? Index: net/if_ethersubr.c === RCS file: /cvs/src/sys/net/if_ethersubr.c,v retrieving revision 1.202 diff -u -p -r1.202 if_ethersubr.c --- net/if_ethersubr.c 2 Jun 2015 09:38:24 - 1.202 +++ net/if_ethersubr.c 2 Jun 2015 10:05:31 - @@ -113,11 +113,6 @@ didn't get a copy, you may request one f #include net/if_vlan_var.h #endif /* NVLAN 0 */ -#include carp.h -#if NCARP 0 -#include netinet/ip_carp.h -#endif - #include pppoe.h #if NPPPOE 0 #include net/if_pppoe.h @@ -243,18 +238,17 @@ ether_addheader(struct mbuf **m, struct * Assumes that ifp is actually pointer to arpcom structure. */ int -ether_output(struct ifnet *ifp0, struct mbuf *m0, struct sockaddr *dst, +ether_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, struct rtentry *rt) { u_int16_t etype; - int len, error = 0; u_char edst[ETHER_ADDR_LEN]; u_char *esrc; struct mbuf *m = m0; struct mbuf *mcopy = NULL; struct ether_header *eh; - struct arpcom *ac = (struct arpcom *)ifp0; - struct ifnet *ifp = ifp0; + struct arpcom *ac = (struct arpcom *)ifp; + int error = 0; #ifdef DIAGNOSTIC if (ifp-if_rdomain != rtable_l2(m-m_pkthdr.ph_rtableid)) { @@ -267,20 +261,6 @@ ether_output(struct ifnet *ifp0, struct esrc = ac-ac_enaddr; -#if NCARP 0 - if (ifp-if_type == IFT_CARP) { - ifp = ifp-if_carpdev; - ac = (struct arpcom *)ifp; - - if ((ifp0-if_flags (IFF_UP|IFF_RUNNING)) != - (IFF_UP|IFF_RUNNING)) - senderr(ENETDOWN); - } - - if (ifp0 != ifp ifp0-if_type == IFT_CARP) - esrc = carp_get_srclladdr(ifp0, esrc); -#endif /* NCARP 0 */ - if ((ifp-if_flags (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) senderr(ENETDOWN); @@ -402,14 +382,7 @@ ether_output(struct ifnet *ifp0, struct } #endif - len = m-m_pkthdr.len; - - error = if_output(ifp, m); -#if NCARP 0 - if (!error ifp != ifp0) - ifp0-if_obytes += len; -#endif /* NCARP 0 */ - return (error); + return (if_output(ifp, m)); bad: if (m) m_freem(m); Index: netinet/ip_carp.c === RCS file: /cvs/src/sys/netinet/ip_carp.c,v retrieving revision 1.258 diff -u -p -r1.258 ip_carp.c --- netinet/ip_carp.c 2 Jun 2015 09:38:24 - 1.258 +++ netinet/ip_carp.c 2 Jun 2015 10:05:31 - @@ -745,7 +745,7 @@ carp_clone_create(struct if_clone *ifc, ifp-if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp-if_ioctl = carp_ioctl; ifp-if_start = carp_start; - IFQ_SET_MAXLEN(ifp-if_snd, IFQ_MAXLEN); + IFQ_SET_MAXLEN(ifp-if_snd, 1); IFQ_SET_READY(ifp-if_snd); if_attach(ifp); ether_ifattach(ifp); @@ -2257,15 +2257,52 @@ carp_ifgattr_ioctl(struct ifnet *ifp, u_ carp_vhe_send_ad_all(sc); } -/* - * Start output on carp interface. This function should never be called. - */ void carp_start(struct ifnet *ifp) { -#ifdef DEBUG - printf(%s: start called\n, ifp-if_xname); -#endif + struct carp_softc *sc = ifp-if_softc; + struct mbuf *m; + + for (;;) { + IFQ_DEQUEUE(ifp-if_snd, m); + if (m == NULL) + break; + +#if NBPFILTER 0 + if (ifp-if_bpf) + bpf_mtap_ether(ifp-if_bpf, m, BPF_DIRECTION_OUT); +#endif /* NBPFILTER 0 */ + + if ((ifp-if_carpdev-if_flags (IFF_UP|IFF_RUNNING)) != + (IFF_UP|IFF_RUNNING)) { + IF_DROP(ifp-if_carpdev-if_snd); + ifp-if_oerrors++; + m_freem(m); + continue; + } + + /* +* Do not leak the multicast address when sending +* advertisements in 'ip' and 'ip-stealth' balacing +* modes. +*/ + if (sc-sc_balancing != CARP_BAL_IPSTEALTH + sc-sc_balancing != CARP_BAL_IP + (sc-cur_vhe !sc-cur_vhe-vhe_leader)) { + struct ether_header *eh; + uint8_t *esrc; + + eh = mtod(m, struct
No #if NVLAN in Ethernet layer
Diff below requires the No NCARP diff I just sent to apply cleanly but should be independent. The idea is to move back the VLAN encapsulation into the vlan(4) driver. As with carp(4) vlan_start() is used. This simplifies the bpf(4) dance and make all our pseudo-driver call bpf_mtap() in the *_start() routine like the ``real'' Ethernet drivers. Ok? diff --git sys/net/if_bridge.c sys/net/if_bridge.c index 7963795..f989aee 100644 --- sys/net/if_bridge.c +++ sys/net/if_bridge.c @@ -2641,11 +2641,6 @@ bridge_fragment(struct bridge_softc *sc, struct ifnet *ifp, m_freem(m); } -#if NVLAN 0 -extern int vlan_output(struct ifnet *, struct mbuf *, struct sockaddr *, -struct rtentry *); -#endif - int bridge_ifenqueue(struct bridge_softc *sc, struct ifnet *ifp, struct mbuf *m) { @@ -2661,45 +2656,6 @@ bridge_ifenqueue(struct bridge_softc *sc, struct ifnet *ifp, struct mbuf *m) ifp-if_ibytes += m-m_pkthdr.len; } #endif -#if NVLAN 0 - /* -* If the underlying interface cannot do VLAN tag insertion itself, -* create an encapsulation header. -*/ - if (ifp-if_output == vlan_output) { - struct ifvlan *ifv = ifp-if_softc; - struct ifnet*p = ifv-ifv_p; - u_int8_tprio = m-m_pkthdr.pf.prio; - - /* IEEE 802.1p has prio 0 and 1 swapped */ - if (prio = 1) - prio = !prio; - - /* should we use the tx tagging hw offload at all? */ - if ((p-if_capabilities IFCAP_VLAN_HWTAGGING) - (ifv-ifv_type == ETHERTYPE_VLAN)) { - m-m_pkthdr.ether_vtag = ifv-ifv_tag + - (prio EVL_PRIO_BITS); - m-m_flags |= M_VLANTAG; - } else { - struct ether_vlan_header evh; - - m_copydata(m, 0, ETHER_HDR_LEN, (caddr_t)evh); - evh.evl_proto = evh.evl_encap_proto; - evh.evl_encap_proto = htons(ifv-ifv_type); - evh.evl_tag = htons(ifv-ifv_tag + - (prio EVL_PRIO_BITS)); - m_adj(m, ETHER_HDR_LEN); - M_PREPEND(m, sizeof(evh), M_DONTWAIT); - if (m == NULL) { - sc-sc_if.if_oerrors++; - return (ENOBUFS); - } - m_copyback(m, 0, sizeof(evh), evh, M_NOWAIT); - m-m_flags = ~M_VLANTAG; - } - } -#endif len = m-m_pkthdr.len; error = if_output(ifp, m); diff --git sys/net/if_ethersubr.c sys/net/if_ethersubr.c index e9c4055..0373701 100644 --- sys/net/if_ethersubr.c +++ sys/net/if_ethersubr.c @@ -108,11 +108,6 @@ didn't get a copy, you may request one from lice...@ipv6.nrl.navy.mil. #include net/if_bridge.h #endif -#include vlan.h -#if NVLAN 0 -#include net/if_vlan_var.h -#endif /* NVLAN 0 */ - #include pppoe.h #if NPPPOE 0 #include net/if_pppoe.h @@ -135,9 +130,6 @@ u_char etherbroadcastaddr[ETHER_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; #define senderr(e) { error = (e); goto bad;} -static inline int ether_addheader(struct mbuf **, struct ifnet *, - u_int16_t, u_char *, u_char *); - int ether_ioctl(struct ifnet *ifp, struct arpcom *arp, u_long cmd, caddr_t data) { @@ -172,79 +164,18 @@ ether_ioctl(struct ifnet *ifp, struct arpcom *arp, u_long cmd, caddr_t data) return (error); } -static inline int -ether_addheader(struct mbuf **m, struct ifnet *ifp, u_int16_t etype, -u_char *esrc, u_char *edst) -{ - struct ether_header *eh; - -#if NVLAN 0 - if ((*m)-m_flags M_VLANTAG) { - struct ifvlan *ifv = ifp-if_softc; - struct ifnet*p = ifv-ifv_p; - u_int8_tprio = (*m)-m_pkthdr.pf.prio; - - /* IEEE 802.1p has prio 0 and 1 swapped */ - if (prio = 1) - prio = !prio; - -#if NBRIDGE 0 - /* -* The bridge might send on non-vlan interfaces -- which -* do not need this header -- or add the vlan-header itself -* in bridge_ifenqueue -- which would add a second header. -*/ - if (ifp-if_bridgeport) - (*m)-m_flags = ~M_VLANTAG; - else -#endif - /* should we use the tx tagging hw offload at all? */ - if ((p-if_capabilities IFCAP_VLAN_HWTAGGING) - (ifv-ifv_type == ETHERTYPE_VLAN)) { - (*m)-m_pkthdr.ether_vtag = ifv-ifv_tag + - (prio EVL_PRIO_BITS); - /* don't return, need to add regular ethernet header */ - } else { - struct ether_vlan_header
Re: [Patch] httpd - don't leak fcgi file descriptors
On Tue, Jun 02, 2015 at 01:50:35PM +0200, Joerg Jung wrote: Am 01.06.2015 um 01:25 schrieb Todd Mortimer t...@opennet.ca: I agree that my patch is more of a workaround, and it would be better to track down how it is that the client is being passed to server_fcgi with an open socket. I was going this way when I started looking at the source, but then I saw that clt-clt_srvevb and clt-clt_srvbev get the same treatment (free if not null, then reassign) at the same spot in server_fcgi(), and I figured if it was good enough for clt_srvevb and clt_srvbev, why not for clt_fd? Yes, you are right. I think your proposed diff is correct. I would like to commit it, if anyone is willing to give OK. This feels to me more like a workaround. Since what happens is that a connection is either reused without cleanup or we call the connection establishment multiple time for the same client. relayd had a similar issue that I fixed lately. One of the issues is that event callbacks can be called when you don't really expect them to be called. Thanks, Regards, Joerg Index: server_fcgi.c === RCS file: /cvs/src/usr.sbin/httpd/server_fcgi.c,v retrieving revision 1.53 diff -u -p -u -p -r1.53 server_fcgi.c --- server_fcgi.c26 Mar 2015 09:01:51 -1.53 +++ server_fcgi.c31 May 2015 22:33:54 - @@ -31,6 +31,7 @@ #include stdio.h #include time.h #include ctype.h +#include unistd.h #include event.h #include httpd.h @@ -152,6 +153,9 @@ server_fcgi(struct httpd *env, struct cl errstr = failed to allocate evbuffer; goto fail; } + +if(clt-clt_fd != -1) +close(clt-clt_fd); clt-clt_fd = fd; if (clt-clt_srvbev != NULL) -- :wq Claudio