FreeBSD Bugzilla – Attachment 92273 Details for
Bug 129881
[patch] net/openospfd: update to 4.3 and fix some bugs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
update-to-4.3-pack3.diff
update-to-4.3-pack3.diff (text/plain), 11.66 KB, created by
Eygene Ryabinkin
on 2008-12-23 12:40:01 UTC
(
hide
)
Description:
update-to-4.3-pack3.diff
Filename:
MIME Type:
Creator:
Eygene Ryabinkin
Created:
2008-12-23 12:40:01 UTC
Size:
11.66 KB
patch
obsolete
>From b7c9024649187eabede98eb12cc7d0bc8e5fa24b Mon Sep 17 00:00:00 2001 >From: Eygene Ryabinkin <rea-fbsd@codelabs.ru> >Date: Tue, 23 Dec 2008 14:53:47 +0300 >Subject: [PATCH 3/3] More fixes to OpenOSPFD > >Add patch for libevent 'event' argument processing: both read >and write flags could be set for a single event. > >Add patch for FreeBSD 8-CURRENT ARP-v2 rework: ARP addresses are >now moved from the main routing table, so there is no need to >check RTF_LLINFO flag. > >Signed-off-by: Eygene Ryabinkin <rea-fbsd@codelabs.ru> >--- > net/openospfd/files/patch-RTF_LLINFO-ARP-v2-fix | 50 ++++ > net/openospfd/files/patch-fix-libevent-READ-WRITE | 300 +++++++++++++++++++++ > 2 files changed, 350 insertions(+), 0 deletions(-) > create mode 100644 net/openospfd/files/patch-RTF_LLINFO-ARP-v2-fix > create mode 100644 net/openospfd/files/patch-fix-libevent-READ-WRITE > >diff --git a/net/openospfd/files/patch-RTF_LLINFO-ARP-v2-fix b/net/openospfd/files/patch-RTF_LLINFO-ARP-v2-fix >new file mode 100644 >index 0000000..f333795 >--- /dev/null >+++ b/net/openospfd/files/patch-RTF_LLINFO-ARP-v2-fix >@@ -0,0 +1,50 @@ >+From 1138f09b72a42ddb7b35780da0e51a0b378bea1b Mon Sep 17 00:00:00 2001 >+From: Eygene Ryabinkin <rea-fbsd@codelabs.ru> >+Date: Mon, 22 Dec 2008 12:13:13 +0300 >+Subject: [PATCH] Fix usage of RTF_LLINFO due to the ARP-v2 changes >+ >+ARP-v2, commited in SVN rev 186119, eliminated RTF_WASCLONE, >+RTF_CLONING and RTF_LLINFO, >+ http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/net/route.h?rev=1.77 >+ >+The latter flag was used in OpenOSPFD to skip ARP entries from the >+routing table. We're just conditionalizing the code on the existence of >+RTF_LLINFO variable. Perhaps checking __FreeBSD__ value will be better: >+errors due to the non-included net/route.h won't be spotted in the >+former case. But since many RTF_* constants are used in kroute.c, this >+shouldn't be a problem, at least now. >+ >+Signed-off-by: Eygene Ryabinkin <rea-fbsd@codelabs.ru> >+--- >+ ospfd/kroute.c | 4 ++++ >+ 1 files changed, 4 insertions(+), 0 deletions(-) >+ >+diff --git a/ospfd/kroute.c b/ospfd/kroute.c >+index b46fa30..acc2a32 100644 >+--- ospfd/kroute.c >++++ ospfd/kroute.c >+@@ -1174,8 +1174,10 @@ fetchtable(void) >+ if ((sa = rti_info[RTAX_DST]) == NULL) >+ continue; >+ >++#if defined(RTF_LLINFO) /* FreeBSD dropped RTF_LLINFO after ARP-v2 rework */ >+ if (rtm->rtm_flags & RTF_LLINFO) /* arp cache */ >+ continue; >++#endif /* defined(RTF_LLINFO) */ >+ >+ if ((kr = calloc(1, sizeof(struct kroute_node))) == NULL) { >+ log_warn("fetchtable"); >+@@ -1371,8 +1373,10 @@ dispatch_rtmsg(void) >+ if (rtm->rtm_errno) /* failed attempts... */ >+ continue; >+ >++#if defined(RTF_LLINFO) /* FreeBSD dropped RTF_LLINFO after ARP-v2 rework */ >+ if (rtm->rtm_flags & RTF_LLINFO) /* arp cache */ >+ continue; >++#endif /* defined(RTF_LLINFO) */ >+ >+ #ifdef RTF_MPATH >+ if (rtm->rtm_flags & RTF_MPATH) >+-- >+1.6.0.4 >+ >diff --git a/net/openospfd/files/patch-fix-libevent-READ-WRITE b/net/openospfd/files/patch-fix-libevent-READ-WRITE >new file mode 100644 >index 0000000..d74e804 >--- /dev/null >+++ b/net/openospfd/files/patch-fix-libevent-READ-WRITE >@@ -0,0 +1,300 @@ >+From 490cb06ef878bff1e45acf313105205df7baced1 Mon Sep 17 00:00:00 2001 >+From: Eygene Ryabinkin <rea-fbsd@codelabs.ru> >+Date: Sun, 21 Dec 2008 15:18:11 +0300 >+Subject: [PATCH] Add processing of both READ and WRITE events inside libevent handlers >+ >+If both read and write descriptors are ready, then libevent will set >+both EV_READ and EV_WRITE. Original OpenOSPFD sources were not ready to >+handle such situations, but OpenBSD's libevent (1.3e with some local >+tweaks) and even libevent 1.0 can also produce combined read/write >+events (if manual page is correct ;). >+ >+Such errors were seen in the wild, for example Remko Lodder had been >+biten by this issue. >+ >+I had created inline function that will be called from both 6 places >+that are handling READ/WRITE events to eliminate code duplication. >+ >+Signed-off-by: Eygene Ryabinkin <rea-fbsd@codelabs.ru> >+--- >+ ospfd/libevent_helpers.h | 81 ++++++++++++++++++++++++++++++++++++++++++++++ >+ ospfd/ospfd.c | 31 ++---------------- >+ ospfd/ospfe.c | 39 ++++----------------- >+ ospfd/rde.c | 31 ++---------------- >+ 4 files changed, 95 insertions(+), 87 deletions(-) >+ create mode 100644 ospfd/libevent_helpers.h >+ >+diff --git a/ospfd/libevent_helpers.h b/ospfd/libevent_helpers.h >+new file mode 100644 >+index 0000000..46f743d >+--- /dev/null >++++ ospfd/libevent_helpers.h >+@@ -0,0 +1,81 @@ >++/* >++ * Copyright (c) 2008 Eygene Ryabinkin <rea-fbsd@codelabs.ru> >++ * >++ * Permission to use, copy, modify, and distribute this software for any >++ * purpose with or without fee is hereby granted, provided that the above >++ * copyright notice and this permission notice appear in all copies. >++ * >++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES >++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF >++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR >++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES >++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN >++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF >++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. >++ */ >++ >++#ifndef _LIBEVENT_HELPERS_H_ >++#define _LIBEVENT_HELPERS_H_ >++ >++#include <stdio.h> >++#include <sys/types.h> >++ >++#include "log.h" >++#include "ospfd.h" >++ >++/* Inline functions */ >++ >++/* >++ * A support function that processes libevent notification in the >++ * following way: >++ * - if we are ready to write, we will try to flush the queue; >++ * - if we are ready to read, we will read the input buffer and >++ * prepare variables 'n' and 'shut' accordingly. >++ * >++ * Such handling occurs at least 6 times within the OSPFD sources, >++ * so this inline function is just an alternative to the preprocessor >++ * macros. >++ * >++ * Function returns 0 if everything was handled and no further >++ * processing is needed; it returns EV_READ if the read processing >++ * was prepared to take place. >++ */ >++static inline short >++dispatch_read_write_event(short _event, struct imsgbuf *_ibuf, >++ ssize_t *_n, int *_shut) __attribute__((always_inline)); >++ >++static inline short >++dispatch_read_write_event(short event, struct imsgbuf *ibuf, >++ ssize_t *n, int *shut) >++{ >++ static char errbuf[128]; >++ >++ /* >++ * We can have both EV_READ and EV_WRITE, since we can be >++ * subscribed to both event types. Handle write readiness >++ * first (flush the queue) and then handle reads. >++ */ >++ if ((event & ~(EV_WRITE|EV_READ))) { >++ snprintf(errbuf, sizeof(errbuf), >++ "unknown event 0x%hx", (unsigned short)event); >++ fatalx(errbuf); >++ } >++ >++ if ((event & EV_WRITE)) { >++ if (msgbuf_write(&ibuf->w) == -1) >++ fatal("msgbuf_write"); >++ imsg_event_add(ibuf); >++ } >++ if ((event & EV_READ)) { >++ if ((*n = imsg_read(ibuf)) == -1) >++ fatal("imsg_read error"); >++ if (*n == 0) /* connection closed */ >++ *shut = 1; >++ return EV_READ; >++ } else { >++ return 0; >++ } >++ /* NOTREACHED */ >++} >++ >++#endif /* _LIBEVENT_HELPERS_H_ */ >+diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c >+index be69cab..4e62d09 100644 >+--- ospfd/ospfd.c >++++ ospfd/ospfd.c >+@@ -46,6 +46,7 @@ >+ #include "control.h" >+ #include "log.h" >+ #include "rde.h" >++#include "libevent_helpers.h" >+ >+ void main_sig_handler(int, short, void *); >+ __dead void usage(void); >+@@ -355,21 +356,8 @@ main_dispatch_ospfe(int fd, short event, void *bula) >+ ssize_t n; >+ int shut = 0; >+ >+- switch (event) { >+- case EV_READ: >+- if ((n = imsg_read(ibuf)) == -1) >+- fatal("imsg_read error"); >+- if (n == 0) /* connection closed */ >+- shut = 1; >+- break; >+- case EV_WRITE: >+- if (msgbuf_write(&ibuf->w) == -1) >+- fatal("msgbuf_write"); >+- imsg_event_add(ibuf); >++ if (dispatch_read_write_event(event, ibuf, &n, &shut) != EV_READ) >+ return; >+- default: >+- fatalx("unknown event"); >+- } >+ >+ for (;;) { >+ if ((n = imsg_get(ibuf, &imsg)) == -1) >+@@ -434,21 +422,8 @@ main_dispatch_rde(int fd, short event, void *bula) >+ ssize_t n; >+ int count, shut = 0; >+ >+- switch (event) { >+- case EV_READ: >+- if ((n = imsg_read(ibuf)) == -1) >+- fatal("imsg_read error"); >+- if (n == 0) /* connection closed */ >+- shut = 1; >+- break; >+- case EV_WRITE: >+- if (msgbuf_write(&ibuf->w) == -1) >+- fatal("msgbuf_write"); >+- imsg_event_add(ibuf); >++ if (dispatch_read_write_event(event, ibuf, &n, &shut) != EV_READ) >+ return; >+- default: >+- fatalx("unknown event"); >+- } >+ >+ for (;;) { >+ if ((n = imsg_get(ibuf, &imsg)) == -1) >+diff --git a/ospfd/ospfe.c b/ospfd/ospfe.c >+index af7a406..d6a6aa9 100644 >+--- ospfd/ospfe.c >++++ ospfd/ospfe.c >+@@ -42,6 +42,7 @@ >+ #include "rde.h" >+ #include "control.h" >+ #include "log.h" >++#include "libevent_helpers.h" >+ >+ void ospfe_sig_handler(int, short, void *); >+ void ospfe_shutdown(void); >+@@ -257,23 +258,11 @@ ospfe_dispatch_main(int fd, short event, void *bula) >+ struct iface *iface = NULL; >+ struct kif *kif; >+ struct auth_md md; >+- int n, link_ok, stub_changed, shut = 0; >+- >+- switch (event) { >+- case EV_READ: >+- if ((n = imsg_read(ibuf)) == -1) >+- fatal("imsg_read error"); >+- if (n == 0) /* connection closed */ >+- shut = 1; >+- break; >+- case EV_WRITE: >+- if (msgbuf_write(&ibuf->w) == -1) >+- fatal("msgbuf_write"); >+- imsg_event_add(ibuf); >++ int link_ok, stub_changed, shut = 0; >++ ssize_t n; >++ >++ if (dispatch_read_write_event(event, ibuf, &n, &shut) != EV_READ) >+ return; >+- default: >+- fatalx("unknown event"); >+- } >+ >+ for (;;) { >+ if ((n = imsg_get(ibuf, &imsg)) == -1) >+@@ -401,24 +390,12 @@ ospfe_dispatch_rde(int fd, short event, void *bula) >+ struct lsa_entry *le; >+ struct imsg imsg; >+ struct abr_rtr ar; >+- int n, noack = 0, shut = 0; >++ int noack = 0, shut = 0; >+ u_int16_t l, age; >++ ssize_t n; >+ >+- switch (event) { >+- case EV_READ: >+- if ((n = imsg_read(ibuf)) == -1) >+- fatal("imsg_read error"); >+- if (n == 0) /* connection closed */ >+- shut = 1; >+- break; >+- case EV_WRITE: >+- if (msgbuf_write(&ibuf->w) == -1) >+- fatal("msgbuf_write"); >+- imsg_event_add(ibuf); >++ if (dispatch_read_write_event(event, ibuf, &n, &shut) != EV_READ) >+ return; >+- default: >+- fatalx("unknown event"); >+- } >+ >+ for (;;) { >+ if ((n = imsg_get(ibuf, &imsg)) == -1) >+diff --git a/ospfd/rde.c b/ospfd/rde.c >+index 5dd0623..faa0c23 100644 >+--- ospfd/rde.c >++++ ospfd/rde.c >+@@ -37,6 +37,7 @@ >+ #include "ospfe.h" >+ #include "log.h" >+ #include "rde.h" >++#include "libevent_helpers.h" >+ >+ void rde_sig_handler(int sig, short, void *); >+ void rde_shutdown(void); >+@@ -239,21 +240,8 @@ rde_dispatch_imsg(int fd, short event, void *bula) >+ int r, state, self, shut = 0; >+ u_int16_t l; >+ >+- switch (event) { >+- case EV_READ: >+- if ((n = imsg_read(ibuf)) == -1) >+- fatal("imsg_read error"); >+- if (n == 0) /* connection closed */ >+- shut = 1; >+- break; >+- case EV_WRITE: >+- if (msgbuf_write(&ibuf->w) == -1) >+- fatal("msgbuf_write"); >+- imsg_event_add(ibuf); >++ if (dispatch_read_write_event(event, ibuf, &n, &shut) != EV_READ) >+ return; >+- default: >+- fatalx("unknown event"); >+- } >+ >+ clock_gettime(CLOCK_MONOTONIC, &tp); >+ now = tp.tv_sec; >+@@ -584,21 +572,8 @@ rde_dispatch_parent(int fd, short event, void *bula) >+ ssize_t n; >+ int shut = 0; >+ >+- switch (event) { >+- case EV_READ: >+- if ((n = imsg_read(ibuf)) == -1) >+- fatal("imsg_read error"); >+- if (n == 0) /* connection closed */ >+- shut = 1; >+- break; >+- case EV_WRITE: >+- if (msgbuf_write(&ibuf->w) == -1) >+- fatal("msgbuf_write"); >+- imsg_event_add(ibuf); >++ if (dispatch_read_write_event(event, ibuf, &n, &shut) != EV_READ) >+ return; >+- default: >+- fatalx("unknown event"); >+- } >+ >+ for (;;) { >+ if ((n = imsg_get(ibuf, &imsg)) == -1) >+-- >+1.6.0.5 >+ >-- >1.6.0.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 129881
: 92273 |
92274