Age | Commit message (Collapse) | Author |
|
lib: introduce Linux route netlink binding
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
# ucode -mrtnl -Rs 'printf("%.J", rtnl.request(rtnl.const.RTM_GETROUTE, 0, { dst: "8.8.8.8" }))'
{
"family": 2,
"tos": 0,
"protocol": 0,
"scope": 0,
"type": 1,
"flags": 512,
"dst": "8.8.8.8/32",
"oif": "onboard",
"gateway": "10.11.12.13",
"prefsrc": "10.11.12.7",
"cacheinfo": {
"clntref": 2,
"lastuse": 0,
"expires": 0,
"error": 0,
"used": 0,
"id": 0,
"ts": 0,
"tsage": 0
},
"table": 254,
"uid": 0
}
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
# ucode -mrtnl -Rs 'printf("%.J", rtnl.request(rtnl.const.RTM_GETLINK, 0, { dev: "lo" }))'
{
"family": 0,
"type": 772,
"dev": "lo",
"flags": 65609,
"address": "00:00:00:00:00:00",
"broadcast": "00:00:00:00:00:00",
"txqlen": 1000,
"mtu": 65536,
"carrier": true,
"linkmode": 0,
"operstate": 0,
"num_tx_queues": 1,
"num_rx_queues": 1,
"af_spec": {
"inet": {
"conf": {
"forwarding": 1,
"mc_forwarding": 0,
"proxy_arp": 0,
"accept_redirects": 1,
"secure_redirects": 1,
"send_redirects": 1,
"shared_media": 1,
"rp_filter": 0,
"accept_source_route": 1,
"bootp_relay": 0,
"log_martians": 0,
"tag": 0,
"arpfilter": 0,
"medium_id": 0,
"noxfrm": 1,
"nopolicy": 1,
"force_igmp_version": 0,
"arp_announce": 0,
"arp_ignore": 0,
"promote_secondaries": 0,
"arp_accept": 0,
"arp_notify": 0,
"accept_local": 0,
"src_vmark": 0,
"proxy_arp_pvlan": 0,
"route_localnet": 0,
"igmpv2_unsolicited_report_interval": 10000,
"igmpv3_unsolicited_report_interval": 1000,
"ignore_routes_with_linkdown": 0,
"drop_unicast_in_l2_multicast": 0,
"drop_gratuitous_arp": 0,
"bc_forwarding": 0
}
},
"inet6": {
"mode": 0,
"flags": 2147483648,
"conf": {
"forwarding": 0,
"hoplimit": 64,
"mtu6": 65536,
"accept_ra": 1,
"accept_redirects": 1,
"autoconf": 1,
"dad_transmits": 1,
"rtr_solicits": -1,
"rtr_solicit_interval": 4000,
"rtr_solicit_delay": 1000,
"use_tempaddr": -1,
"temp_valid_lft": 604800,
"temp_prefered_lft": 86400,
"regen_max_retry": 3,
"max_desync_factor": 600,
"max_addresses": 16,
"force_mld_version": 0,
"accept_ra_defrtr": 1,
"accept_ra_pinfo": 1,
"accept_ra_rtr_pref": 1,
"rtr_probe_interval": 60000,
"accept_ra_rt_info_max_plen": 0,
"proxy_ndp": 0,
"optimistic_dad": 0,
"accept_source_route": 0,
"mc_forwarding": 0,
"disable_ipv6": 0,
"accept_dad": -1,
"force_tllao": 0,
"ndisc_notify": 0,
"mldv1_unsolicited_report_interval": 10000,
"mldv2_unsolicited_report_interval": 1000,
"suppress_frag_ndisc": 1,
"accept_ra_from_local": 0,
"use_optimistic": 0,
"accept_ra_mtu": 1,
"stable_secret": 0,
"use_oif_addrs_only": 0,
"accept_ra_min_hop_limit": 1,
"ignore_routes_with_linkdown": 0,
"drop_unicast_in_l2_multicast": 0,
"drop_unsolicited_na": 0,
"keep_addr_on_down": 0,
"rtr_solicit_max_interval": 3600000,
"seg6_enabled": 0,
"seg6_require_hmac": 0,
"enhanced_dad": 1,
"addr_gen_mode": 0,
"disable_policy": 0,
"accept_ra_rt_info_min_plen": 0,
"ndisc_tclass": 0,
"rpl_seg_enabled": 0
}
}
},
"proto_down": false,
"group": 0,
"ifname": "lo"
}
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Some netlink replies contain attributes with embeded payloads whose
length depends on the kernel version, e.g. IFLA_INET_CONF and
IFLA_INET6_CONF.
Deal with such cases by allowing the payloads to be shorter than
the expected size and by skipping struct members which would lead
to out-of-bounds accesses.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
In success case, always push the function return value onto the stack even
if no call frames are remaining after the function returned.
This is needed for host program code invoking ucode functions within a VM
context that already ran to completion.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Fixes: dfb7379 ("fs: implement chmod(), chown(), rename() and glob() functions")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The Fuzz test implementation so far is just boilerplate and fails due to
imposed memory limits on the CI runner.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Mark reachable native function and ucode function objects during incremental
GC steps in order to avoid freeing them prematurely.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Fixes: c79ff39 ("types: handle conversion errors when dealing with negative error indexes")
Fixes: 3315b1f ("types: allow negative array indexes")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Also apply the same logic to array set operations.
Fixes: 3315b1f ("types: allow negative array indexes")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Support array[-1], array[-2] etc. to retrieve elements relative to the end
of the array values.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
C API wip
|
|
- Ensure that most functions follow the subject_verb naming schema
- Move type related function from value.c to types.c
- Rename value.c to vallist.c
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Provide separate public ucv_gc() and ucv_freeall() functions to perform
an incremental and complete GC run respectively.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When attempting to invoke uc_vm_free() or uc_gc() on a uc_vm_t struct
that has not been initialized by uc_vm_init(), the circular double
linked value list is not set up, causing the GC to read invalid memory
locations when attempting to traverse the object list.
Back out early when the list heads are not properly set up in order to
prevent this issue.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Set VM options and environment variables and load modules on the fly
while parsing the cli options instead of aggregating all the values in
memory first.
This vastly reduces the amount of arguments we need to pass to the
parse() function. Also rename parse() to compile() while we're at it.
Also slightly adjust the usage output.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Ensure that all custom typedef and vector declaration type names end with
a "_t" suffix.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Add a public getter and setter to read and set the VM trace level
respectively. Use the new API to control the trace mode with a newly
introduced `-t` command line switch.
Drop support for honouring the `TRACE` environment variable as
host programs embedding ucode might want to prevent that behaviour
or handle it differently.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
So far, the VM simply printed exception information to stderr if the
exception was not catched in managed code. Host programs embedding
ucode might want to customize that behaviour, so refactor the current
defualt behaviour into a callback function and add a public getter
and setter to allow changing the exception handler callback.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When a function is invoked directly, e.g. through uc_vm_invoke(), the call
stack is empty, so avoid accessing the first call frame unless we actually
need to, which is only the case if the function is invoked with spread args
which can only happen with calls from manged code.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When a toplevel function call raises an exception, the call stack will be
empty when invoking the exception handler, ensure to handle this case
appropriately.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Instead of invoking exit(3) from uc_exit(), use a new EXCEPTION_EXIT
exception type to instruct the VM to shutdown cleanly.
This is required to not terminate the host program in case libucode
is embedded and loaded scripts invoke the exit() function.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Module preloading is a cli frontend specific feature, it does not belong
into the VM API, therfore do the module preloading directly in main.c to
allow removing the corresponding VM code in a subsequent commit.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The uc_vm_invoke() function simplifies calling a named ucode function with
arbitrary arguments.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The naming is an artifact from before the introduction of the new type
system. In the current code, there is nothing special about prototypes,
they're simple object values.
Also introduce a new singular uc_add_function() convenience macro while
we're at it.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
This is a cosmetic change to bring the code in line with the common prefix
format of the other code in the tree.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Only assert non-zero refcount for objects which haven't been marked for
freeing yet.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
If there's only native function calls on the call stack, the code
incorrectly accessed an invalid memory location.
Avoid that issue by stopping the search for non-native callframes
before the last frame.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Ensure to increase the refcount of the module scope value when caching it
in the global module registry to avoid a double free on VM teardown.
Fixes: 96f140b ("lib, vm: ensure that require() compiles modules only once")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Cache the result of a successful require operation in a global.modules
object and return the cached value for subsequent require calls on the
same module name.
This ensures that a given module is only compiled and executed once,
regardless of how many times it is used.
A reload of the module can be forced by deleting the corresponding
key in the global module table.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|