Documentation
¶
Overview ¶
* Copyright 2025 Alexandre Mahdhaoui * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright 2025 Alexandre Mahdhaoui * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright 2025 Alexandre Mahdhaoui * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright 2025 Alexandre Mahdhaoui * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrEBPFObjectsMustNotBeNil = errors.New("ebpf objects must not be nil") ErrCreatingNewArray = errors.New("creating new array") )
var ( ErrAnotherProcessAlreadySubscribed = errors.New("another process already subscribed") ErrSubscribingToFIFO = errors.New("subscribing to fifo") )
var ErrCreatingNewVariable = errors.New("creating new variable")
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array[T any] interface { // Done returns a channel that's closed when work done on behalf of this // interface has been gracefully terminated. Done() <-chan struct{} // -- Set all values of the BPF map to the one of the input map. // - DELETE all entries in the *ebpf.Map that have index > newLen. // - UPDATE_BATCH all entries with index in the interval [0, newLen]. // -- Set new length if changed: // - SET a.length. // - a.oldLen = newLen. Set(values []T) error // SetAndDeferSwitchover updates the passive internal map but does // not perform the switchover. // // It allows users to "pseudo-atomically" update multiple BPF data // structures from the bpf-program point of view, by sharing the same // "activePointer" bpf variable with multiple BPF data structures. // // SetAndDeferSwitchover returns a function that can be called once to // perform the switchover. // The returned function can only be called once. // Please note that the returned function will retry if errors are // encountered. // // The deferable switchover function must be called, even if the same // "activePointer" bpf variable is used for multiple data structures. // The deferable switchover function must be called because it updates // internal variables in userspace. SetAndDeferSwitchover(values []T) (func(), error) }
Wraps bpf objects with a convenient interface for testing.
type FIFO ¶
type FIFO[T any] interface { // Done returns a channel that's closed when work done on behalf of this // interface has been gracefully terminated. // // While the channel from Subscribe() could be used to know if the FIFO // interface has been closed, using the channel from this interface is // more idiomatic. Done() <-chan struct{} // Subscribe returns a receiver channel of T or an error. Subscribe() (<-chan T, error) }
FIFO[T] can be used to subscribe to structured notifications produced by a bpf program.
Generics constraints: - T must be a **struct**. - T must not be a pointer. - T must not be an interface.
Notes: - FIFO is thread-safe. - Subscribe() can be called only once.
type Map ¶
type Map[K comparable, V any] interface { // Done returns a channel that's closed when work done on behalf of this // interface has been gracefully terminated. Done() <-chan struct{} // Update in batch a set of entries in the ACTIVE map. // This method does not perform a switchover. // This method mutates the ACTIVE map. BatchUpdate(kv map[K]V) error // Delete in batch a set of keys from the ACTIVE map. // This method does not perform a switchover. // This method mutates the ACTIVE map. BatchDelete([]K) error // Set all values of the BPF map to the one of the input map. Set(newMap map[K]V) error // SetAndDeferSwitchover updates the passive internal map but does // not perform the switchover. // // It allows users to "pseudo-atomically" update multiple BPF data // structures from the bpf-program point of view, by sharing the same // "activePointer" bpf variable with multiple BPF data structures. // // SetAndDeferSwitchover returns a function that can be called once to // perform the switchover. // The returned function can only be called once. // Please note that the returned function will retry if errors are // encountered. // // The deferable switchover function must be called, even if the same // "activePointer" bpf variable is used for multiple data structures. // The deferable switchover function must be called because it updates // internal variables in userspace. SetAndDeferSwitchover(newMap map[K]V) (func(), error) }
Wraps bpf objects with a convenient interface for testing.
type Variable ¶
type Variable[T any] interface { // Done returns a channel that's closed when work done on behalf of this // interface has been gracefully terminated. Done() <-chan struct{} // Set the variable. Set(v T) error }
This is only used in order to write tests. No fancy feature. Maybe in the future add support for:
- Get()
- caching & no-cache for Get().
- Set with differable switchover in order to sync switchover with many bpf data structures.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
util
* Copyright 2025 Alexandre Mahdhaoui * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
|
* Copyright 2025 Alexandre Mahdhaoui * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |
|
pkg
|
|
|
fakebpfstruct
* Copyright 2025 Alexandre Mahdhaoui * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
|
* Copyright 2025 Alexandre Mahdhaoui * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |