Feb 15, 2014

Kernel. Networking

struct sk_buff

struct net_device
devices: eth ppp asdn atm
rx recieve
tz transmit

Explicit Congestion Notification (ECN) — (Явное Уведомление о Перегруженности)
ls -l /sys/class/net

cat /proc/net/sockstat
cat /proc/net/dev
cat /proc/net/tcp  # ports
cat /proc/net/udp
cat /proc/net/unix
Nearly all cards support DMA mode

IPv4
IPv6

UDP
TCP

mtu maximum transmission unit
ARP address resolution protocol
NAT network address translation; masquerading
transparent proxy
netfilter; iptables
finite state machine конечный автомат
tcpdump witeshark
tshark -V -2 -R 'ip.addr==208.118.235.148'

# http://stackoverflow.com/questions/5907527/application-control-of-tcp-retransmission-on-linux
/proc/sys/net/ipv4/tcp_retries2

man 5 socketckall

man 3 netlink
man 5 netlink
/proc/net/netlink

Feb 10, 2014

Unix as IDE. Man

man -k someterm
apropos someterm

info -k printf
info coreutils printf

Feb 5, 2014

Dia

sudo aptitude install autodia
autodia -l python -D -H -m -K -k -A -i test.py
autodia -l DBI -i "mysql:databasename:localhost" -U root -P pass

Feb 3, 2014

Extended file attributes, ACL

Does file system support?
sudo tune2fs -l /dev/sda1 | grep "Default mount options:"
# Default mount options:    user_xattr acl
Extended file attributes

Extended attributes: the good, the not so good, the bad.
On Linux and FreeBSD, cp will only preserve xattrs if given the option --preserve=xattr, also implied by the -a option. cp will not duplicate attributes by default, which is a reasonable default choice, even if it will be wrong in some situations (where you will have to use the options).

Extended Attributes – lsattr and chattr
  • a : append only 
  • c : compressed 
  • d : no dump 
  • e : extent format 
  • i : immutable 
  • j : data journalling 
  • s : secure deletion 
  • t : no tail-merging 
  • u : undeletable 
  • A : no atime updates 
  • C : no copy on write 
  • D : synchronous directory updates 
  • S : synchronous updates 
  • T : top of directory hierarchy
lsattr test.txt
chattr -a test.txt
SELinux (англ. Security-Enhanced Linux — Linux с улучшенной безопасностью) — реализация системы принудительного контроля доступа, которая может работать параллельно с классической дискреционной системой контроля доступа. Входит в стандартное ядро Linux. Также для функционирования SELinux требуются модифицированные версии некоторых утилит (ps, ls, и тд), которые обеспечивают поддержку новых функций ядра, и поддержка со стороны файловой системы.
setfattr -n user.comment -v "this is a comment" testfile
getfattr testfile
# user.comment
getfattr -n user.comment testfile
# user.comment="this is a comment"

POSIX Access Control Lists on Linux
DAC model
man 5 acl
getfacl dir
setfacl -m user:joe:rwx dir
man chacl

GCC, DDD

gcc
# -S to output assembly
gcc -O0 -S hello.c
# -masm=intel or -masm=att

ddd
gcc -g -c sample sample.c
ddd sample

ddd --disassemble sample

X86 Registers