OpenBSD CVS

CVS log for src/usr.sbin/bgpd/Attic/imsg.c


[BACK] Up to [local] / src / usr.sbin / bgpd

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.51, Wed May 26 16:44:32 2010 UTC (14 years ago) by nicm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.50: +1 -1 lines
FILE REMOVED

Move imsg into libutil and add a man page.

Minor bump for libutil.

Previous versions of this diff and man page looked at by various people.

"you should just commit" deraadt

Revision 1.50 / (download) - annotate - [select for diffs], Wed May 26 13:56:07 2010 UTC (14 years ago) by nicm
Branch: MAIN
Changes since 1.49: +11 -11 lines
Diff to previous 1.49 (colored)

Rename some imsg bits to make namespace collisions less likely buf to
ibuf, buf_read to ibuf_read, READ_BUF_SIZE to IBUF_READ_SIZE.

ok henning gilles claudio jacekm deraadt

Revision 1.49 / (download) - annotate - [select for diffs], Wed Apr 7 18:09:39 2010 UTC (14 years, 2 months ago) by nicm
Branch: MAIN
Changes since 1.48: +2 -2 lines
Diff to previous 1.48 (colored)

Remove XXX comment and just close received fd if calloc() fails.

If this happens the imsg may no longer be usable as there may be queued
messages, but this is a) already the case with the code now, and b)
would be the case if recvmsg() fails anyway, so we can document that -1
from imsg_read() invalidates the struct imsgbuf.

discussed with and ok eric

Revision 1.48 / (download) - annotate - [select for diffs], Sat Aug 8 18:33:40 2009 UTC (14 years, 10 months ago) by nicm
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.47: +6 -3 lines
Diff to previous 1.47 (colored)

Make imsg_clear close and free any fds in the received fd queue as well as
freeing the msgbuf.

While here also remove an unnecessary while loop.

ok eric pyr

Revision 1.47 / (download) - annotate - [select for diffs], Mon Jun 8 08:30:06 2009 UTC (15 years ago) by dlg
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.46: +4 -11 lines
Diff to previous 1.46 (colored)

revert this change by eric@:

Make the imsg protocol network-safe.


it might be network safe, but half the imsg based daemons on my firewalls
dont run anymore.

Revision 1.46 / (download) - annotate - [select for diffs], Sun Jun 7 05:56:24 2009 UTC (15 years ago) by eric
Branch: MAIN
Changes since 1.45: +15 -3 lines
Diff to previous 1.45 (colored)

Change the way fds passed over a socket are retreived on the receiving side.

Currently the receiver fetches an imsg via imsg_get() and if he expects
an fd, he then calls imsg_get_fd() to fetch the next fd queued on the
imsgbuf from which the imsg came.

This changes hides the fd queueing mechanism to the API user.  When closing
an imsg with an fd, the message is flagged so that the receiving end knows
it must dequeue the fd in imsg_get() and return it with the imsg structure.
This way there is no (less) possible screw up from imsg_get_fd() not being
called directly after imsg_get() by the user. The retreived imsg is
self-contained.

ok pyr@, "I like that" henning@

Revision 1.45 / (download) - annotate - [select for diffs], Sun Jun 7 00:40:46 2009 UTC (15 years ago) by eric
Branch: MAIN
Changes since 1.44: +11 -3 lines
Diff to previous 1.44 (colored)

Make the imsg protocol network-safe.

ok pyr@

Revision 1.44 / (download) - annotate - [select for diffs], Sat Jun 6 22:11:25 2009 UTC (15 years ago) by eric
Branch: MAIN
Changes since 1.43: +4 -3 lines
Diff to previous 1.43 (colored)

change the imsg header fields a bit to prepare for upcoming changes.
add a flag field, use u_int32_t for pid_t and extend type to 32 bits
for padding.

ok pyr@

Revision 1.43 / (download) - annotate - [select for diffs], Sat Jun 6 06:33:15 2009 UTC (15 years ago) by eric
Branch: MAIN
Changes since 1.42: +71 -38 lines
Diff to previous 1.42 (colored)

sync bgpd/bgpctl with the common imsg code, making it lib ready as well.

ok claudio@ pyr@

Revision 1.42 / (download) - annotate - [select for diffs], Mon Mar 24 16:11:02 2008 UTC (16 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.41: +2 -2 lines
Diff to previous 1.41 (colored)

msg_controllen has to be CMSG_SPACE so that the kernel can account for
each cmsg_len (ie. msg_controllen = sum of CMSG_ALIGN(cmsg_len).  This
works now that kernel fd passing has been fixed to accept a bit of
sloppiness because of this ABI repair.
lots of discussion with kettenis

Revision 1.41 / (download) - annotate - [select for diffs], Sat Mar 15 16:25:00 2008 UTC (16 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.40: +2 -2 lines
Diff to previous 1.40 (colored)

Repair more msg_controllen dealing with structures or arrays of
descriptors; ok hshoexer, also looked at by kettenis and henning

Revision 1.40 / (download) - annotate - [select for diffs], Thu Mar 13 01:49:53 2008 UTC (16 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.39: +7 -4 lines
Diff to previous 1.39 (colored)

Correct CMSG_SPACE and CMSG_LEN usage everywhere in the tree. Due to
an extensive discussion with otto, kettenis, millert, and hshoexer

Revision 1.39 / (download) - annotate - [select for diffs], Mon Mar 19 10:03:25 2007 UTC (17 years, 2 months ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3, OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.38: +2 -2 lines
Diff to previous 1.38 (colored)

when our red/recv/recvmsg in imsg_read gives EINTR or EAGAIN, do not
signal "connection closed" upstream.
spotted by Valentin Kozamernik <tin@komna.com>

Revision 1.38 / (download) - annotate - [select for diffs], Sat May 27 19:59:44 2006 UTC (18 years ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1, OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.37: +3 -2 lines
Diff to previous 1.37 (colored)

if the pid given to imsg_create is 0, use the pid sored in the ibuf (which
is the current process' pid). fixes blocking with concurrent bgpctl
instances... oups. surprised we missed that earlier, the pid stuff was only
ever added for that purposed, but we missed to set the pid. gigantic oups.
with & ok claudio

Revision 1.37 / (download) - annotate - [select for diffs], Wed Nov 2 15:34:43 2005 UTC (18 years, 7 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.36: +3 -3 lines
Diff to previous 1.36 (colored)

Mark some additional function arguments as const.

Revision 1.36 / (download) - annotate - [select for diffs], Tue Apr 26 15:18:22 2005 UTC (19 years, 1 month ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.35: +3 -3 lines
Diff to previous 1.35 (colored)

unify shared code a bit again to make future syncs easier
From: Alexander von Gernler <grunk@pestilenz.org>

Revision 1.35 / (download) - annotate - [select for diffs], Wed Mar 23 10:46:27 2005 UTC (19 years, 2 months ago) by henning
Branch: MAIN
Changes since 1.34: +2 -3 lines
Diff to previous 1.34 (colored)

ssize_t -> size_t, from ntpd, there from Alexander von Gernler

Revision 1.34 / (download) - annotate - [select for diffs], Wed Mar 9 14:08:03 2005 UTC (19 years, 3 months ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.33: +2 -2 lines
Diff to previous 1.33 (colored)

correctness: memmove instead of memcpy where we might have overlaps

Revision 1.33 / (download) - annotate - [select for diffs], Fri Sep 17 11:49:19 2004 UTC (19 years, 8 months ago) by claudio
Branch: MAIN
Changes since 1.32: +2 -2 lines
Diff to previous 1.32 (colored)

Fix log message

Revision 1.32 / (download) - annotate - [select for diffs], Thu Sep 16 17:58:13 2004 UTC (19 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.31: +4 -4 lines
Diff to previous 1.31 (colored)

imsg type is really an enum imsg_type and not an int

Revision 1.31 / (download) - annotate - [select for diffs], Thu Sep 16 17:36:29 2004 UTC (19 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.30: +13 -80 lines
Diff to previous 1.30 (colored)

imsg API cleanup:
-kill imsg_compose_pid, imsg_compose_fdpass and imsg_create_pid
-extend the original imsg_compose/_create API to take pid & fd too
-make imsg_compose do imsg_create + imsg_add + imsg_close instead of
 duplicating the code
-adjust all callers to the new API
ok claudio

Revision 1.30 / (download) - annotate - [select for diffs], Thu Aug 19 10:40:14 2004 UTC (19 years, 9 months ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.29: +17 -2 lines
Diff to previous 1.29 (colored)

better diagnostics

Revision 1.29 / (download) - annotate - [select for diffs], Wed Aug 11 10:10:28 2004 UTC (19 years, 10 months ago) by claudio
Branch: MAIN
Changes since 1.28: +2 -2 lines
Diff to previous 1.28 (colored)

Typo. OK henning@

Revision 1.28 / (download) - annotate - [select for diffs], Mon Jul 5 02:13:44 2004 UTC (19 years, 11 months ago) by henning
Branch: MAIN
Changes since 1.27: +2 -2 lines
Diff to previous 1.27 (colored)

fix a few KNF fallouts

Revision 1.27 / (download) - annotate - [select for diffs], Sun Jun 20 18:07:06 2004 UTC (19 years, 11 months ago) by henning
Branch: MAIN
Changes since 1.26: +4 -3 lines
Diff to previous 1.26 (colored)

allow for receival of up to 16 fds at once; after discussion with theo

Revision 1.26 / (download) - annotate - [select for diffs], Sun Jun 20 17:49:46 2004 UTC (19 years, 11 months ago) by henning
Branch: MAIN
Changes since 1.25: +62 -8 lines
Diff to previous 1.25 (colored)

implement file descriptor passing in the imsg/msgbuf framework, and use
it to let the main process to prepare new listening sockets (socket() and
bind()) on behalf of the session engine, which of course cannot bind() to
ports < 1024 any more once it dropped privileges. with some help from theo,
claudio ok

Revision 1.25 / (download) - annotate - [select for diffs], Thu Apr 29 19:56:04 2004 UTC (20 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.24: +5 -5 lines
Diff to previous 1.24 (colored)

sock -> fd; ok henning

Revision 1.24 / (download) - annotate - [select for diffs], Fri Mar 12 20:48:09 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.23: +3 -3 lines
Diff to previous 1.23 (colored)

tweak err reporting

Revision 1.23 / (download) - annotate - [select for diffs], Mon Feb 16 14:26:29 2004 UTC (20 years, 3 months ago) by claudio
Branch: MAIN
Changes since 1.22: +66 -3 lines
Diff to previous 1.22 (colored)

Extend imsg API so that messages can be composed on the fly. In the RDE it
happens often, that imsg consists of multiple objects. OK henning@

Revision 1.22 / (download) - annotate - [select for diffs], Thu Jan 22 20:34:56 2004 UTC (20 years, 4 months ago) by henning
Branch: MAIN
Changes since 1.21: +6 -6 lines
Diff to previous 1.21 (colored)

use log_warnx and log_info. reclassify a few messages in the process and fix
a few messages.

ok claudio@

Revision 1.21 / (download) - annotate - [select for diffs], Thu Jan 22 03:18:03 2004 UTC (20 years, 4 months ago) by henning
Branch: MAIN
Changes since 1.20: +3 -3 lines
Diff to previous 1.20 (colored)

s/log_err/log_warn/
it is like warn(3), nor err(3). so use a less confusing name.

Revision 1.20 / (download) - annotate - [select for diffs], Fri Jan 9 13:47:07 2004 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.19: +20 -1 lines
Diff to previous 1.19 (colored)

get us a stateful imsg relaying framework, and the first receiver,
IMSG_CTL_KROUTE, to have the kroute structs forming the fib sent to a
control socket.

ok claudio@

Revision 1.19 / (download) - annotate - [select for diffs], Tue Jan 6 03:43:50 2004 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.18: +2 -2 lines
Diff to previous 1.18 (colored)

2004

Revision 1.18 / (download) - annotate - [select for diffs], Sat Jan 3 14:06:35 2004 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.17: +3 -7 lines
Diff to previous 1.17 (colored)

change imsg_read semantics so that the number of bytes read is returned.
that means that the callers can (and must) coope with closed connections
themselves, what is exactly the desired behaviour.

Revision 1.17 / (download) - annotate - [select for diffs], Thu Jan 1 23:46:47 2004 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.16: +2 -2 lines
Diff to previous 1.16 (colored)

listen on a AF_LOCAL socket for imsgs too.
only implemented type yet is IMSG_CTL_SHOW_NEIGHBOR which sends back
the struct peer for all neighbors.
will be used by bgpdctl

Revision 1.16 / (download) - annotate - [select for diffs], Thu Jan 1 23:40:25 2004 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.15: +2 -2 lines
Diff to previous 1.15 (colored)

typo

Revision 1.15 / (download) - annotate - [select for diffs], Thu Jan 1 23:09:09 2004 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.14: +18 -7 lines
Diff to previous 1.14 (colored)

now that imsg_get uses bigger buffers, one read call can put more than one
imsg into the buffer. since imsg_get by definition only returns one imsg we
missed the next imsg(s) until the next poll event on the socket in question,
building up a queue on that socket. didn't show up as a problem yet...
factor out imsg_read, which reads into the buffer. imsg_get now entirely
operates on the buffers and does not read(2) itself.
make all callers cope by calling imsg_read on poll events and calling
imsg_get in a loop until all imsgs are processed.

Revision 1.14 / (download) - annotate - [select for diffs], Tue Dec 30 22:42:31 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.13: +4 -4 lines
Diff to previous 1.13 (colored)

correctly free after buf_add/_close errs.
From: Patrick Latifi <pat@eyeo.org>

Revision 1.13 / (download) - annotate - [select for diffs], Tue Dec 30 20:59:43 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.12: +4 -1 lines
Diff to previous 1.12 (colored)

missing free()s in error cases that (now) lead to program termination
From: Patrick Latifi <pat@eyeo.org>

Revision 1.12 / (download) - annotate - [select for diffs], Sun Dec 28 14:34:30 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.11: +42 -57 lines
Diff to previous 1.11 (colored)

redo the imsg readers to use bigger buffers and less read(2)s. should increase
performance even further.
gets rif od struct imsg_readbuf; rename peer_read_buf to read_buf as that
is more appropriate now.

Revision 1.11 / (download) - annotate - [select for diffs], Fri Dec 26 18:33:11 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.10: +29 -15 lines
Diff to previous 1.10 (colored)

let imsg_get and imsg_compose not fatal() but return errors upstream.
make the callers cope.

Revision 1.10 / (download) - annotate - [select for diffs], Fri Dec 26 18:07:32 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.9: +8 -8 lines
Diff to previous 1.9 (colored)

when this project started and i added the fatal() function, I made it take
the error number as parameter instead of accessing errno, because in one
place the error number was not in errno but fetched from a socket.
now, of course it makes much more sense to just set errno to the error number
just fecthed in this one place instead of having hundreds of fatal() calls
all transfer the errno round and round and round...
fix this, and also provide a fatalx, which does not care for errno and doesn't
invoke strerror.
oh, btw, in the place where we fetch the err # from the socket, we don't
call fatal anymore anyway...

Revision 1.9 / (download) - annotate - [select for diffs], Wed Dec 24 13:28:02 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.8: +3 -3 lines
Diff to previous 1.8 (colored)

handle write() returning 0 correctly, adjust the msgbuf API appropriately,
and make all callers cope.

Revision 1.8 / (download) - annotate - [select for diffs], Sun Dec 21 23:28:39 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.7: +2 -2 lines
Diff to previous 1.7 (colored)

rename get_imsg() to imsg_get(); that's more consistent

Revision 1.7 / (download) - annotate - [select for diffs], Sun Dec 21 23:26:37 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.6: +35 -26 lines
Diff to previous 1.6 (colored)

wrap read & write buffers for imsgs into a struct.
finally gives us read buffers per pipe instead of per process, eleminating
a possible race.
also gets us a real imsg_init() that does all the boring init work

Revision 1.6 / (download) - annotate - [select for diffs], Sun Dec 21 22:16:53 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.5: +8 -8 lines
Diff to previous 1.5 (colored)

overhaul the write buffering code.
introduce msgbuf API and bundle all info needed for the write buffers in a
struct msgbuf.
also switch to a write queue per handled connection (each bgp session, each
pipe) instead of one big one.
fixes some subtle problems and is overall nicer.

ok claudio@

Revision 1.5 / (download) - annotate - [select for diffs], Sat Dec 20 21:19:40 2003 UTC (20 years, 5 months ago) by claudio
Branch: MAIN
Changes since 1.4: +2 -2 lines
Diff to previous 1.4 (colored)

more cast cleanup imsg_compose takes now a void * argument. OK henning@

Revision 1.4 / (download) - annotate - [select for diffs], Sat Dec 20 21:14:55 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored)

let buf_add take void *data instead of u_char *data and save a zillion
evil casts

Revision 1.3 / (download) - annotate - [select for diffs], Sat Dec 20 18:39:05 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.2: +5 -3 lines
Diff to previous 1.2 (colored)

fatal() is a bit too much on 0 bytes read. imsg_get returns 0 in other
cases as well and all receivers cope

Revision 1.2 / (download) - annotate - [select for diffs], Sat Dec 20 14:33:09 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.1: +2 -2 lines
Diff to previous 1.1 (colored)

read(2)/write(2) return ssize_t, not size_t

Revision 1.1 / (download) - annotate - [select for diffs], Wed Dec 17 11:46:54 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN

welcome, bgpd
started by me some time ago with moral support from theo, the proceeded up to
the point where the session engine worked correctly. claudio jeker joined
then and did a lot of work in the RDE.
it is not particulary usefull as application right now as parts are still
missing but is imported to enable more people to work on it.
status:
BGP sessions get established fine, OPEN messages and then KEEPALIVEs
exchanged etc. session FSM works fine; NOTIFICATIONs are handled fine, and
all connection drops etc I provoked get handled fine.
Incoming UPDATE messgages are parsed well and the data entered to the RIB,
the decision process is not yet there, neither is outgoing UPDATEs or sync
to the kernel routing table.

not connected to the builds yet.

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.