OpenBSD CVS

CVS log for src/lib/libutil/imsg.c


[BACK] Up to [local] / src / lib / libutil

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.23 / (download) - annotate - [select for diffs], Tue Dec 12 15:47:41 2023 UTC (5 months, 4 weeks ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, HEAD
Changes since 1.22: +143 -31 lines
Diff to previous 1.22 (colored)

Extend imsg and ibuf API with useful getter methods

For ibufs:
- various getters for ibufs (ibuf_get* and ibuf_skip)
- additional ibuf set/add functions that don't alter byte order
- ibuf_truncate and ibuf_rewind
- ibuf_from_buffer and ibuf_from_ibuf to populate a reader ibuf
- a getter for the msgbuf queuelen

For imsg:
- various getters for imsg (especially imsg_get_data() which can be used
  in most cases as a simple one call api with all error checks).
  All the imsg.hdr fields can also be accessed by getters.
- The imsg data is now actually an ibuf but the old imsg.data pointer is
  kept for now to not break every imsg application.
- Introduce imsg_forward to simply forward a message from one channel to
  an other (used in the control socket code).

Since this requires a major bump take the oportunity to also cleanup some
function signatures to use size_t for length fields. Also internal data
structures are removed from the public header.

With and OK tb@

Revision 1.22 / (download) - annotate - [select for diffs], Sat Nov 18 07:14:13 2023 UTC (6 months, 3 weeks ago) by claudio
Branch: MAIN
Changes since 1.21: +5 -5 lines
Diff to previous 1.21 (colored)

Rename internal function imsg_get_fd() to imsg_dequeue_fd().
OK tb@

Revision 1.21 / (download) - annotate - [select for diffs], Fri Nov 17 15:35:15 2023 UTC (6 months, 3 weeks ago) by claudio
Branch: MAIN
Changes since 1.20: +10 -10 lines
Diff to previous 1.20 (colored)

The term peerid originated from bgpd. It is time to generalize this and
just call it id. This only targets the function arguments but not the
struct imsg_hdr field since that is a major API break.
OK tb@

Revision 1.20 / (download) - annotate - [select for diffs], Fri Nov 17 13:43:32 2023 UTC (6 months, 3 weeks ago) by claudio
Branch: MAIN
Changes since 1.19: +47 -47 lines
Diff to previous 1.19 (colored)

rename struct imsgbuf *ibuf to *imsgbuf since ibuf is too close to
struct ibuf and just causes confusion for little gain.

OK tb@ stsp@

Revision 1.19 / (download) - annotate - [select for diffs], Mon Jun 19 17:19:50 2023 UTC (11 months, 3 weeks ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.18: +42 -8 lines
Diff to previous 1.18 (colored)

Improve the ibuf API by adding these functions:
Functions extending ibuf_add to work with more specific data types
  ibuf_add_buf, ibuf_add_zero, ibuf_add_n8, ibuf_add_n16, ibuf_add_n32,
  ibuf_add_n64
Functions replacing ibuf_seek where data at a specific offset is modified
  ibuf_set, ibuf_set_n8, ibuf_set_n16, ibuf_set_n32, ibuf_set_n64
Functions to check, get and set the filedescriptor stored on the ibuf
  ibuf_fd_avail, ibuf_fd_get, ibuf_fd_set
and ibuf_data() to access the data buffer, to be used together with ibuf_size()

On top of this add an optimized imsg_compose_ibuf() where an ibuf is wrapped
into an imsg in an efficent way.

Finally remove msgbuf_drain since it is not used by anything outside of
the ibuf code. Because of this removal bump the major of libutil.

Remove ibuf_data() in iked since the same function is now provided by libutil.
OK tb@

Revision 1.18 / (download) - annotate - [select for diffs], Wed Mar 8 04:43:05 2023 UTC (15 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.17: +1 -2 lines
Diff to previous 1.17 (colored)

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@

Revision 1.17 / (download) - annotate - [select for diffs], Fri Jan 28 10:41:44 2022 UTC (2 years, 4 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.16: +3 -2 lines
Diff to previous 1.16 (colored)

Only memcpy() into imsg->data if datalen is not 0. Passing a NULL pointer
to memcpy() is UB no matter if len is 0.
Reported by fouzhe on openbgpd-portable github page.
OK tb@

Revision 1.16 / (download) - annotate - [select for diffs], Thu Dec 14 09:27:44 2017 UTC (6 years, 5 months ago) by kettenis
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6, OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.15: +3 -3 lines
Diff to previous 1.15 (colored)

Make a few internal symbols static and add a Symbols.map version script
to control which symbols are exported from the shared library.

ok guenther@, deraadt@, jca@

Revision 1.15 / (download) - annotate - [select for diffs], Tue Apr 11 09:57:19 2017 UTC (7 years, 2 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.14: +2 -2 lines
Diff to previous 1.14 (colored)

Use freezero(3) for the imsg framework in imsg_free(3) and ibuf_free(3).

In our privsep model, imsg is often used to transport sensitive
information between processes.  But a process might free an imsg, and
reuse the memory for a different thing.  iked uses some
explicit_bzero() to clean imsg-buffer but doing it in the library with
the freezero() is less error-prone and also benefits other daemons.

OK deraadt@ jsing@ claudio@

Revision 1.14 / (download) - annotate - [select for diffs], Fri Mar 24 09:34:12 2017 UTC (7 years, 2 months ago) by nicm
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.13: +9 -9 lines
Diff to previous 1.13 (colored)

Use C99 types (uint32_t) instead of BSD (u_int32_t) - the former are
more portable. Add stdint.h to the headers in imsg_init(3).

No objections from millert@.

Revision 1.13 / (download) - annotate - [select for diffs], Wed Dec 9 11:54:12 2015 UTC (8 years, 6 months ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.12: +2 -2 lines
Diff to previous 1.12 (colored)

Add a cast to silence a compiler warning by clang on FreeBSD.
From Craig Rodrigues.
ok tedu@

Revision 1.12 / (download) - annotate - [select for diffs], Sat Dec 5 13:06:52 2015 UTC (8 years, 6 months ago) by claudio
Branch: MAIN
Changes since 1.11: +4 -6 lines
Diff to previous 1.11 (colored)

Do not loop on EAGAIN in imsg_read(). Better to return the error to the
caller and let him do another poll loop. This fixes spinning relayd
processes seen on busy TLS relays. OK benno@ henning@

Revision 1.11 / (download) - annotate - [select for diffs], Fri Nov 27 01:57:59 2015 UTC (8 years, 6 months ago) by mmcc
Branch: MAIN
Changes since 1.10: +2 -3 lines
Diff to previous 1.10 (colored)

Remove three NULL-checks before free().   ok millert@

Revision 1.10 / (download) - annotate - [select for diffs], Sun Jul 19 07:18:59 2015 UTC (8 years, 10 months ago) by nicm
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.9: +4 -2 lines
Diff to previous 1.9 (colored)

Handle malloc(0) returning NULL (which can happen on some other
platforms) by explicitly making imsg->data = NULL when there is no
data. ok deraadt

Revision 1.9 / (download) - annotate - [select for diffs], Sun Jul 12 18:40:49 2015 UTC (8 years, 11 months ago) by nicm
Branch: MAIN
Changes since 1.8: +5 -5 lines
Diff to previous 1.8 (colored)

Use memset instead of bzero for better portability.

ok gilles claudio doug

Revision 1.8 / (download) - annotate - [select for diffs], Fri Jul 3 14:50:14 2015 UTC (8 years, 11 months ago) by brynet
Branch: MAIN
Changes since 1.7: +2 -1 lines
Diff to previous 1.7 (colored)

bzero cmsgbuf before using it, silences valgrind warnings.

henning@ "sure"

Revision 1.7 / (download) - annotate - [select for diffs], Thu Jun 11 19:25:53 2015 UTC (9 years ago) by reyk
Branch: MAIN
Changes since 1.6: +2 -2 lines
Diff to previous 1.6 (colored)

The correct semantic is to check msgbuf_write() for <= 0, not just < 0.
Fix one occurence in imsg_flush() and clarify it the man page.

Discussed with at least blambert@ jsg@ yasuoka@.

OK gilles@

Revision 1.6 / (download) - annotate - [select for diffs], Mon Jun 30 00:26:22 2014 UTC (9 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7, OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.5: +2 -2 lines
Diff to previous 1.5 (colored)

sys/types.h rather than sys/param.h, where applicable.  avoid overreach.

Revision 1.5 / (download) - annotate - [select for diffs], Thu Dec 26 17:32:33 2013 UTC (10 years, 5 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.4: +3 -3 lines
Diff to previous 1.4 (colored)

constify data parameter in imsg_add() and imsg_compose()

ok deraadt@

Revision 1.4 / (download) - annotate - [select for diffs], Fri Feb 1 15:22:18 2013 UTC (11 years, 4 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.3: +2 -1 lines
Diff to previous 1.3 (colored)

fix memleak in imsg_read() when hitting the fd reserve check

ok millert@, mikeb@, lteo@

Revision 1.3 / (download) - annotate - [select for diffs], Wed Dec 19 13:37:12 2012 UTC (11 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.2: +2 -2 lines
Diff to previous 1.2 (colored)

Fix a purely theoretical NULL-pointer dereference in the case that we
would be able to receive multiple SCM_RIGHTS messages.

ok claudio@ gilles@

Revision 1.2 / (download) - annotate - [select for diffs], Sat Jun 2 21:46:53 2012 UTC (12 years ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.1: +43 -13 lines
Diff to previous 1.1 (colored)

in imsg_read() avoid calling recvmsg() if we detect that we will be short
on descriptors, this can be achieved thanks to the new getdtablecount()
system call. application may provide a reserve count to ensure that the
recvmsg() call is not called when they don't have enough descriptors to
work properly.

change the API so that transient errors that can be retried immediately
are retried within the function right away, whereas transient errors for
which the application may want to take action will set errno to EAGAIN.

ok deraadt@ and henning@

Revision 1.1 / (download) - annotate - [select for diffs], Wed May 26 16:44:32 2010 UTC (14 years ago) by nicm
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8

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

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.