@@ -5857,6 +5857,41 @@ static const struct bpf_func_proto bpf_tcp_check_syncookie_proto = {
58575857#endif /* CONFIG_INET */
58585858
58595859#ifdef CONFIG_XDPLUA
5860+ BPF_CALL_2 (bpf_lua_dataref , struct xdp_buff * , ctx , int , offset ) {
5861+ if (offset + ctx -> data < ctx -> data_end ) {
5862+ int data_ref ;
5863+
5864+ data_ref = ldata_newref (ctx -> L , ctx -> data + offset ,
5865+ ctx -> data_end - ctx -> data - offset );
5866+ return data_ref ;
5867+ }
5868+
5869+ return -1 ;
5870+ }
5871+
5872+ static const struct bpf_func_proto bpf_lua_dataref_proto = {
5873+ .func = bpf_lua_dataref ,
5874+ .gpl_only = false,
5875+ .pkt_access = false,
5876+ .ret_type = RET_INTEGER ,
5877+ .arg1_type = ARG_PTR_TO_CTX ,
5878+ .arg1_type = ARG_ANYTHING ,
5879+ };
5880+
5881+ BPF_CALL_2 (bpf_lua_dataunref , struct xdp_buff * , ctx , int , data_ref ) {
5882+ ldata_unref (ctx -> L , data_ref );
5883+ return 0 ;
5884+ }
5885+
5886+ static const struct bpf_func_proto bpf_lua_dataunref_proto = {
5887+ .func = bpf_lua_dataunref ,
5888+ .gpl_only = false,
5889+ .pkt_access = false,
5890+ .ret_type = RET_VOID ,
5891+ .arg1_type = ARG_PTR_TO_CTX ,
5892+ .arg2_type = ARG_ANYTHING ,
5893+ };
5894+
58605895BPF_CALL_4 (bpf_lua_pcall , struct xdp_buff * , ctx , char * , funcname ,
58615896 int , num_args , int , num_rets ) {
58625897 if (lua_getglobal (ctx -> L , funcname ) != LUA_TFUNCTION ) {
@@ -6106,6 +6141,10 @@ bpf_base_func_proto(enum bpf_func_id func_id)
61066141 case BPF_FUNC_trace_printk :
61076142 return bpf_get_trace_printk_proto ();
61086143#ifdef CONFIG_XDPLUA
6144+ case BPF_FUNC_lua_dataref :
6145+ return & bpf_lua_dataref_proto ;
6146+ case BPF_FUNC_lua_dataunref :
6147+ return & bpf_lua_dataunref_proto ;
61096148 case BPF_FUNC_lua_pcall :
61106149 return & bpf_lua_pcall_proto ;
61116150 case BPF_FUNC_lua_pop :
0 commit comments