Unix 程式碼演進的記錄

GitHub 上的「dspinellis/unix-history-repo」專案放進了 Unix 程式碼從 1970 年演進到 2016 年的記錄:

The history and evolution of the Unix operating system is made available as a revision management repository, covering the period from its inception in 1970 as a 2.5 thousand line kernel and 26 commands, to 2016 as a widely-used 27 million line system.

主要的目的是讓研究人員可以直接分析,減少重複的工作:

The project aims to put in the repository as much metadata as possible, allowing the automated analysis of Unix history.

後面的分支主要是以 FreeBSD 為主:(在列表的部份也可以看到)

It has been created by synthesizing with custom software 24 snapshots of systems developed at Bell Labs, the University of California at Berkeley, and the 386BSD team, two legacy repositories, and the modern repository of the open source FreeBSD system.

整個 repository 頗壯觀的 XD

FreeBSD 11.0 重新發行...

本來已經發行的 FreeBSD 11.0,因為最近的安全性問題 (應該是講 OpenSSL?),決定不以 security update 的方式更新,而是直接發新版了:「[REVISED] [HEADS-UP] 11.0-RELEASE status update」。

Although the FreeBSD 11.0-RELEASE has not yet been officially announced, many have found images on the Project FTP mirrors.

However, please be aware the final 11.0-RELEASE will be rebuilt and republished on the Project mirrors as a result of a few last-minute security fixes we feel are imperative to include in the final release.

我以為應該是發 11.0.1,然後把架上的 11.0 拿掉...

Libreboot 成功的讓 FreeBSD/OpenBSD 開機

Libreboot 是一個 open source 版本的 BIOS/UEFI 替代品:

Libreboot is a free BIOS or UEFI replacement (free as in freedom); libre boot firmware that initializes the hardware and starts a bootloader for your operating system.

而最近的版本則是順利的在沒有修改作業系統來配合 Libreboot 的情況下將 FreeBSDOpenBSD (不過是 kOpenBSD) 開起來了:「Re: [Libreboot] GNU Libreboot, version 20160818 released」。

Netflix 對 sendfile() 在 TLS 情況下的加速

Netflix 對於寫了一篇關於隱私保護的技術細節:「Protecting Netflix Viewing Privacy at Scale」。

其中講到 2012 年的 Netflix Open Connect 中的 Open Connect Appliance (OCA,放伺服器到 ISP 機房的計畫) 只有單台伺服器 8Gbps,到現在 2016 可以達到 90Gbps:

As we mentioned in a recent company blog post, since the beginning of the Open Connect program we have significantly increased the efficiency of our OCAs - from delivering 8 Gbps of throughput from a single server in 2012 to over 90 Gbps from a single server in 2016.

早期的 Netflix 走 sendfile() 將影片丟出去,這在 kernel space 處理,所以很有效率:

當影片本身改走 HTTPS (TLS) 時,其中一個遇到的效能問題是導致 sendfile() 無法使用,而必須在 userland space 加密後改走回傳統的 write() 架構,這對於效能影響很大:

所以他們就讓 kernel 支援 AES 系列加密 (包括 AES-GCM 與 AES-CBC),效能的提昇大約是 30%:

Our changes in both the BoringSSL and ISA-L test situations significantly increased both CPU utilization and bandwidth over baseline - increasing performance by up to 30%, depending on the OCA hardware version.

文章開頭也有提到選 AES-GCM 與 AES-CBC 的一些來龍去脈,主要是 AES-GCM 的安全強度比較好,另外考慮到舊的 client 不支援 AES-GCM 時會使用 AES-CBC:

We evaluated available and applicable ciphers and decided to primarily use the Advanced Encryption Standard (AES) cipher in Galois/Counter Mode (GCM), available starting in TLS 1.2. We chose AES-CGM over the Cipher Block Chaining (CBC) method, which comes at a higher computational cost. The AES-GCM cipher algorithm encrypts and authenticates the message simultaneously - as opposed to AES-CBC, which requires an additional pass over the data to generate keyed-hash message authentication code (HMAC). CBC can still be used as a fallback for clients that cannot support the preferred method.

另外 OCA 機器本身也都夠新,支援 AES-NI 指令集,效能上不是太大的問題:

All revisions of Open Connect Appliances also have Intel CPUs that support AES-NI, the extension to the x86 instruction set designed to improve encryption and decryption performance. We needed to determine the best implementation of AES-GCM with the AES-NI instruction set, so we investigated alternatives to OpenSSL, including BoringSSL and the Intel Intelligent Storage Acceleration Library (ISA-L).

不過在「Netflix Open Connect Appliance Deployment Guide」(26 July 2016 版) 這份文件裡看起來還是用多條 10Gbps 透過 LACP 接上去:

You must be able to provision 2-4 x 10 Gbps ethernet ports in a LACP LAG per OCA. The exact quantity depends on the OCA type.

可能是下一版準備要上 40Gbps 或 100Gbps 的準備...?

Microsoft Azure 宣佈正式支援 FreeBSD

Microsoft Azure 宣佈支援 FreeBSD:「Microsoft has created its own FreeBSD image. Repeat. Microsoft has created its own FreeBSD image」,Microsoft 的正式公告在這:「FreeBSD now available in Azure Marketplace」。

Microsoft 所作的 patch 都有進 10.3-RELEASE 裡,主要是對於 Hyper-V 虛擬化後的效能補強:

The majority of the investments we make at the kernel level to enable network and storage performance were up-streamed into the FreeBSD 10.3 release, so anyone who downloads a FreeBSD 10.3 image from the FreeBSD Foundation will get those investments from Microsoft built in to the OS.

像是 10Gbps 網路這部份就有明顯的改善:

For example, our measured networking throughput on a 10Gb network on FreeBSD 10.1 was 2Gbps. With 10.3, we’ve been able to achieve over 9Gbps in testing

不過我覺得宣傳意義比實質意義重一些...

DigitalOcean 支援 FreeBSD

DigitalOcean 宣佈支援 FreeBSD:「Presenting FreeBSD! How We Made It Happen.」。

不過不是全部的 region 都支援,由於 NYC1、NYC2 與 AMS1 這三個地區的架構比較舊,除了這三個以外的地區都支援 FreeBSD。

文章裡有說明技術上的架構,除了 infrastructure 的支援以外,另外也受益於 bsd-cloudinit

不過自從 FreeBSD 換到 Bugzilla 後,我就把 ports maintainership 都轉移出去,再加上桌機與跳板機都改用 Ubuntu,用 FreeBSD 的情況愈來愈少了...

Ubuntu 12.04 上用 KVM (CLI) 裝 FreeBSD

過年後在家裡弄了一台技嘉的準系統跑 Ubuntu 12.04,結果手上突然沒機器可以跑 porttools 測試,而這台機器平常也沒接鍵盤,就想直接跑 command line 的 KVMFreeBSD。其實知道方式後就很簡單,只是一開始沒弄懂花了不少時間...

首先是安裝 KVM,這部份用 apt-get install kvm 就可以拉下來裝好了。

真正要做的第一部是先用 qemu-img 建立 40GB 的 disk image (qcow2):

qemu-img create -f qcow2 ~/vm/image.qcow2 40G

然後直接用 iso image 安裝 (抓 iso image 的事情也跳過去請各位自己來),設為 4 CPU (-smp 4)、1024MB RAM (-m 1024),並且透過 serial console 安裝 (-nographic -curses),開機先從 cdrom 上開 (-boot d):

kvm -smp 4 -drive file=/abs/path/vm/image.qcow2,if=virtio -cdrom /abs/path/vm/FreeBSD-10.0-RELEASE-amd64-bootonly.iso -m 1024 -nographic -curses -net nic,model=e1000 -net tap -boot d

其中網路的部份卡了最久,後來發現預設值的 -net nic -net user 意思是:

  • -net nic 表示在 Guest OS 內建立一張網卡接到 KVM 的 vlan0。
  • -net user 表示在 KVM 的 vlan0 上建使用 userland mode NAT。

由於 userland mode NAT 很受限 (只有 TCP 與 UDP 會通),所以我用 -net nic -net tap 表示直接 bridge 到 virbr0 上再 NAT 出去。而我希望對 Guest OS 使用 e1000,所以最後就變成 -net nic,e1000 -net tap

接下來安裝 FreeBSD 時就可以用 DHCP mode 抓到 IP 了,由於我希望可以從 Host 直接連進去,所以我是設成 static IP。

裝完後就不需要掛 cdrom 與優先從 cdrom 開始開:

kvm -smp 4 -drive file=/abs/path/vm/image.qcow2,if=virtio -m 1024 -nographic -curses -net nic,model=e1000 -net tap

先前用 -hda /abs/path/vm/image.qcow2 掛上去,結果 i/o 很慢,被 delphij 提醒後改跑 virtio,速度就正常多了。不過這是因為 FreeBSD 10 就內建支援 virtio 了,如果是使用 FreeBSD 9 的需要另外再透過 ports 裝進去。

記錄下來給需要的人玩看看,下次也許應該玩玩看 VNC display?

FreeBSD 對 OpenSSH 的安全性更新...

讓我意外的是,只有 FreeBSD 10.0-BETA (還沒出 RELEASE 的版本) 有問題,9.2-RELEASE 並不在內:「OpenSSH AES-GCM memory corruption vulnerability」。

本來 9.2 的機器有上 workaround 把 AES-GCM 強制拔掉,看起來可以 revert 回來了...

FreeBSD 10 的改變...

Zite 上看到 FreeBSD 10 的改變:「FreeBSD 10's New Technologies and Features」。

最耀眼的當然是對 GCC 的宣戰達到高潮,第一個將預設編譯器換掉的 major release。同樣的,也把 GNU 的 libstdc++ 換成 MIT license 實作的 libc++。

再來是 ISCBIND 被換掉,改用 Unbound 以及 LDNS

然後 UFS 檔案系統可以透過 growfs(8) 線上長大... XDDD

其他的改善包括了 iSCSI stack 重寫,PF 防火牆可以善用 SMP 資源,以及 ZFS 的更新。等正式出版後應該還是會等到 10.1 再上 production 吧?感覺 compiler 一換不知道會有多少雷啊 XD

FreeBSD 的 portconf 新功能...

1.5 版的 portsconf 只能處理等號形式:

lang/php5*: WITH_FPM=yes

前幾天發現這對於某些設定很難處理,所以就在 ports/181119 送出 patch,讓 portconf 可以處理 += 的用法,讓設定更彈性。

結果發現作者就順便把去年十月的 ports/172355 債也還掉... 去年十月這個 pr 早就處理 += 需求,還修正變數名稱需要支援 -+ 的問題。