Skip to content

Commit

Permalink
added DNSErrNo
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Oct 31, 2023
1 parent bc2e5e2 commit 8c786f2
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 3 deletions.
12 changes: 12 additions & 0 deletions config/sample-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,14 @@ frontend:
filter: dns_flag_response_code
default: true
width: 5
- id: DNSErrNo
group: DNS
name: DNS Error
tooltip: DNS error number returned by bpf_skb_load_bytes function.
field: DnsErrno
filter: dns_errno
default: false
width: 5
filters:
- id: src_namespace
name: Namespace
Expand Down Expand Up @@ -760,6 +768,10 @@ frontend:
- A IANA RCODE number like 0, 3, 9
- A IANA RCODE name like NoError, NXDomain, NotAuth
docUrl: https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6
- id: dns_errno
name: DNS Error
component: autocomplete
hint: Specify a single DNS error number.
- id: time_flow_rtt
name: Flow RTT
component: number
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/netflow-traffic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ export const NetflowTraffic: React.FC<{
col =>
(!isSidePanel || !col.isCommon) &&
(isConnectionTracking() || ![ColumnsId.recordtype, ColumnsId.hashid].includes(col.id)) &&
(isDNSTracking() || ![ColumnsId.dnsid, ColumnsId.dnslatency, ColumnsId.dnsresponsecode].includes(col.id)) &&
(isDNSTracking() ||
![ColumnsId.dnsid, ColumnsId.dnslatency, ColumnsId.dnsresponsecode, ColumnsId.dnserrno].includes(col.id)) &&
(isFlowRTT() || ![ColumnsId.rttTime].includes(col.id))
);
},
Expand Down
1 change: 1 addition & 0 deletions web/src/model/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type FilterId =
| 'dns_id'
| 'dns_latency'
| 'dns_flag_response_code'
| 'dns_errno'
| 'time_flow_rtt';

export interface FilterConfigDef {
Expand Down
1 change: 1 addition & 0 deletions web/src/utils/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export enum ColumnsId {
dnsid = 'DNSId',
dnslatency = 'DNSLatency',
dnsresponsecode = 'DNSResponseCode',
dnserrno = 'DNSErrNo',
hostaddr = 'K8S_HostIP',
srchostaddr = 'SrcK8S_HostIP',
dsthostaddr = 'DstK8S_HostIP',
Expand Down
48 changes: 48 additions & 0 deletions web/src/utils/dns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,51 @@ export type DNS_CODE_NAMES = typeof dnsRcodesNames[number];
export const getDNSRcodeDescription = (name: DNS_CODE_NAMES): string => {
return DNS_RCODES.find(v => v.name === name)?.description || 'Unassigned';
};

// https://elixir.bootlin.com/linux/v4.7/source/include/uapi/asm-generic/errno-base.h
export const DNS_ERRORS: ReadOnlyValues = [
{ value: 1, name: 'EPERM', description: 'Operation not permitted' },
{ value: 2, name: 'ENOENT', description: 'No such file or directory' },
{ value: 3, name: 'ESRCH', description: 'No such process' },
{ value: 4, name: 'EINTR', description: 'Interrupted system call' },
{ value: 5, name: 'EIO', description: 'I/O error' },
{ value: 6, name: 'ENXIO', description: 'No such device or address' },
{ value: 7, name: 'E2BIG', description: 'Argument list too long' },
{ value: 8, name: 'ENOEXEC', description: 'Exec format error' },
{ value: 9, name: 'EBADF', description: 'Bad file number' },
{ value: 10, name: 'ECHILD', description: 'No child processes' },
{ value: 11, name: 'EAGAIN', description: 'Try again' },
{ value: 12, name: 'ENOMEM', description: 'Out of memory' },
{ value: 13, name: 'EACCES', description: 'Permission denied' },
{ value: 14, name: 'EFAULT', description: 'Bad address' },
{ value: 15, name: 'ENOTBLK', description: 'Block device required' },
{ value: 16, name: 'EBUSY', description: 'Device or resource busy' },
{ value: 17, name: 'EEXIST', description: 'File exists' },
{ value: 18, name: 'EXDEV', description: 'Cross-device link' },
{ value: 19, name: 'ENODEV', description: 'No such device' },
{ value: 20, name: 'ENOTDIR', description: 'Not a directory' },
{ value: 21, name: 'EISDIR', description: 'Is a directory' },
{ value: 22, name: 'EINVAL', description: 'Invalid argument' },
{ value: 23, name: 'ENFILE', description: 'File table overflow' },
{ value: 24, name: 'EMFILE', description: 'Too many open files' },
{ value: 25, name: 'ENOTTY', description: 'Not a typewriter' },
{ value: 26, name: 'ETXBSY', description: 'Text file busy' },
{ value: 27, name: 'EFBIG', description: 'File too large' },
{ value: 28, name: 'ENOSPC', description: 'No space left on device' },
{ value: 29, name: 'ESPIPE', description: 'Illegal seek' },
{ value: 30, name: 'EROFS', description: 'Read-only file system' },
{ value: 31, name: 'EMLINK', description: 'Too many links' },
{ value: 32, name: 'EPIPE', description: 'Broken pipe' },
{ value: 33, name: 'EDOM', description: 'Math argument out of domain of func' },
{ value: 34, name: 'ERANGE', description: 'Math result not representable' }
] as const;

const dnsErrorsValues = DNS_ERRORS.map(v => v.value);
export type DNS_ERRORS_VALUES = typeof dnsErrorsValues[number];

const dnsErrorsNames = DNS_ERRORS.map(v => v.name);
export type DNS_ERRORS_NAMES = typeof dnsErrorsNames[number];

export const getDNSErrorDescription = (value: DNS_ERRORS_VALUES): string => {
return DNS_ERRORS.find(v => v.value === value)?.description || '';
};
5 changes: 4 additions & 1 deletion web/src/utils/filter-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
getDropStateOptions,
getDropCauseOptions,
getDirectionOptionsAsync,
findDirectionOption
findDirectionOption,
getDnsErrorCodeOptions
} from './filter-options';
import { ColumnConfigDef } from './columns';

Expand Down Expand Up @@ -287,6 +288,8 @@ export const getFilterDefinitions = (
getOptions = cap10(getDropCauseOptions);
} else if (d.id.includes('dns_flag_response_code')) {
getOptions = cap10(getDnsResponseCodeOptions);
} else if (d.id.includes('dns_errno')) {
getOptions = cap10(getDnsErrorCodeOptions);
}
return { getOptions, validate, encoder, checkCompletion };
};
Expand Down
10 changes: 9 additions & 1 deletion web/src/utils/filter-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FlowDirection } from '../api/ipfix';
import { FilterOption } from '../model/filters';
import { splitResource, SplitStage } from '../model/resource';
import { autoCompleteCache } from './autocomplete-cache';
import { DNS_RCODES } from './dns';
import { DNS_ERRORS, DNS_RCODES } from './dns';
import { getPort, getService } from './port';
import { DROP_CAUSES, DROP_STATES } from './pkt-drop';
import { TFunction } from 'i18next';
Expand Down Expand Up @@ -125,6 +125,14 @@ export const getDnsResponseCodeOptions = (value: string): Promise<FilterOption[]
);
};

export const getDnsErrorCodeOptions = (value: string): Promise<FilterOption[]> => {
return Promise.resolve(
DNS_ERRORS.filter(
opt => String(opt.value).includes(value) || opt.name.toLowerCase().includes(value.toLowerCase())
).map(v => ({ name: v.name, value: String(v.value) }))
);
};

export const findProtocolOption = (nameOrVal: string) => {
return protocolOptions.find(p => p.name.toLowerCase() === nameOrVal.toLowerCase() || p.value === nameOrVal);
};
Expand Down

0 comments on commit 8c786f2

Please sign in to comment.