On 01/15, Jakub Kicinski wrote: > On Tue, 15 Jan 2019 15:22:46 -0800, Stanislav Fomichev wrote: > > This patch series add support for queue/stack manipulations. > > > > It goes like this: > > > > #1 and #2 add support for queue/stack in existing 'update' and 'lookup' > > commands by permitting empty keys. > > #3 make sure we don't print empty keys for queue/stack. > > #4 adds peek command, it's essentially an alias for 'lookup'. > > #5 adds push/enqueue commands, an alias to 'update'. > > #6 adds pop/dequeue commands that use bpf_map_lookup_and_delete_elem. > > > > (Not sure whether it makes sense to have push/enqueue + pop/dequeue or > > just have push/pop for both stack/queue, comments are welcome). > > Other than one part of last patch looks good! > > I'd personally be tempted to only allow the peek/push/pop commands for > stacks/queues, i.e. for maps which don't have a key. Right now even > though the help says: > > **bpftool** **map peek** *MAP* > > it's just an alias to lookup, so key can be specified.. > > Could bash completions also only suggest them when the map type is > right (and perhaps vice versa - not suggest lookup etc.)? I can look into bash completion. I'm not at all familiar with it.
Also, let me maybe add some checks in the do_lookup/do_update which print an error in case key is specified when info->key_size is zero (and the same for value).