Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145415326
D54162.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D54162.id.diff
View Options
diff --git a/sys/netlink/netlink_snl.h b/sys/netlink/netlink_snl.h
--- a/sys/netlink/netlink_snl.h
+++ b/sys/netlink/netlink_snl.h
@@ -106,6 +106,26 @@
return (data);
}
+static inline bool
+lb_extendz(struct linear_buffer *lb, void *old, u_int old_len, u_int new_len)
+{
+ u_int delta;
+
+ /* Is the old buffer the last allocated region in the lb? */
+ old_len = roundup2(old_len, alignof(__max_align_t));
+ if ((char *)old + old_len != lb->base + lb->offset)
+ return (false);
+
+ /* Is there room to grow the end of the lb? */
+ new_len = roundup2(new_len, alignof(__max_align_t));
+ delta = new_len - old_len;
+ if (delta > lb->size - lb->offset)
+ return (false);
+
+ lb->offset += delta;
+ return (true);
+}
+
static inline void
lb_clear(struct linear_buffer *lb)
{
@@ -221,6 +241,12 @@
return (data);
}
+static inline bool
+snl_extendz(struct snl_state *ss, void *old, u_int old_len, u_int new_len)
+{
+ return (lb_extendz(ss->lb, old, old_len, new_len));
+}
+
static inline void
snl_clear_lb(struct snl_state *ss)
{
@@ -1093,6 +1119,11 @@
if (nw->error)
return (false);
+ if (snl_extendz(nw->ss, nw->base, nw->size, new_size)) {
+ nw->size = new_size;
+ return (true);
+ }
+
new_base = snl_allocz(nw->ss, new_size);
if (new_base == NULL) {
nw->error = true;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Feb 20, 1:47 PM (10 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27416414
Default Alt Text
D54162.id.diff (1 KB)
Attached To
Mode
D54162: netlink: Optimize growing the snl_writer message buffer
Attached
Detach File
Event Timeline
Log In to Comment