Skip to content

Commit 299ec8f

Browse files
Andrew Boiecarlescufi
authored andcommitted
userspace: net sockets are kernel objects
Any data structure declaration tagged with __net_socket will end up in the kernel object table with type K_OBJ_NET_SOCKET. These all correspond to objects which are associated with socket file descriptors and can handle the socket vtable API. Signed-off-by: Andrew Boie <[email protected]>
1 parent 5960119 commit 299ec8f

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

include/toolchain/common.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,17 @@
132132
#define __syscall
133133
#endif /* #ifndef ZTEST_UNITTEST */
134134

135-
/* Used as a sentinel by parse_syscalls.py to identify what API structs
136-
* define driver subsystems.
135+
/* Definitions for struct declaration tags. These are sentinel values used by
136+
* parse_syscalls.py to gather a list of names of struct declarations that
137+
* have these tags applied for them.
137138
*/
139+
140+
/* Indicates this is a driver subsystem */
138141
#define __subsystem
139142

143+
/* Indicates this is a network socket object */
144+
#define __net_socket
145+
140146
#ifndef BUILD_ASSERT
141147
/* Compile-time assertion that makes the build to fail.
142148
* Common implementation swallows the message.

scripts/gen_kobject_list.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
#
8181
# - The third items is a boolean indicating whether this item can be
8282
# dynamically allocated with k_object_alloc()
83+
#
84+
# Key names in all caps do not correspond to a specific data type but instead
85+
# indicate that objects of its type are of a family of compatible data
86+
# structures
8387

8488
# Regular dictionaries are ordered only with Python 3.6 and
8589
# above. Good summary and pointers to official documents at:
@@ -97,6 +101,7 @@
97101
("k_timer", (None, False, True)),
98102
("z_thread_stack_element", (None, False, False)),
99103
("device", (None, False, False)),
104+
("NET_SOCKET", (None, False, False)),
100105
("sys_mutex", (None, True, False)),
101106
("k_futex", (None, True, False))
102107
])
@@ -118,6 +123,9 @@ def kobject_to_enum(kobj):
118123
#};
119124
]
120125

126+
# Names of all structs tagged with __net_socket, found by parse_syscalls.py
127+
net_sockets = [ ]
128+
121129
def subsystem_to_enum(subsys):
122130
return "K_OBJ_DRIVER_" + subsys[:-11].upper()
123131

@@ -402,6 +410,8 @@ def analyze_die_struct(die):
402410
type_env[offset] = KobjectType(offset, name, size)
403411
elif name in subsystems:
404412
type_env[offset] = KobjectType(offset, name, size, api=True)
413+
elif name in net_sockets:
414+
type_env[offset] = KobjectType(offset, "NET_SOCKET", size)
405415
else:
406416
at = AggregateType(offset, name, size)
407417
type_env[offset] = at
@@ -919,6 +929,7 @@ def parse_subsystems_list_file(path):
919929
with open(path, "r") as fp:
920930
subsys_list = json.load(fp)
921931
subsystems.extend(subsys_list["__subsystem"])
932+
net_sockets.extend(subsys_list["__net_socket"])
922933

923934
def parse_args():
924935
global args

scripts/parse_syscalls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
[)] # Closing parenthesis
4141
''', regex_flags)
4242

43-
struct_tags = ["__subsystem"]
43+
struct_tags = ["__subsystem", "__net_socket"]
4444

4545
tagged_struct_decl_template = r'''
4646
%s\s+ # tag, must be first

0 commit comments

Comments
 (0)