mac80211: remove pointless mesh path timer RCU code
[deliverable/linux.git] / net / mac80211 / key.c
CommitLineData
1f5a7e47
JB
1/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
3b96766f 5 * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net>
1f5a7e47
JB
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
11a843b7
JB
12#include <linux/if_ether.h>
13#include <linux/etherdevice.h>
14#include <linux/list.h>
d4e46a3d 15#include <linux/rcupdate.h>
db4d1169 16#include <linux/rtnetlink.h>
5a0e3ad6 17#include <linux/slab.h>
1f5a7e47
JB
18#include <net/mac80211.h>
19#include "ieee80211_i.h"
24487981 20#include "driver-ops.h"
1f5a7e47
JB
21#include "debugfs_key.h"
22#include "aes_ccm.h"
3cfcf6ac 23#include "aes_cmac.h"
1f5a7e47 24
11a843b7 25
dbbea671
JB
26/**
27 * DOC: Key handling basics
11a843b7
JB
28 *
29 * Key handling in mac80211 is done based on per-interface (sub_if_data)
30 * keys and per-station keys. Since each station belongs to an interface,
31 * each station key also belongs to that interface.
32 *
b5c34f66
JB
33 * Hardware acceleration is done on a best-effort basis for algorithms
34 * that are implemented in software, for each key the hardware is asked
35 * to enable that key for offloading but if it cannot do that the key is
36 * simply kept for software encryption (unless it is for an algorithm
37 * that isn't implemented in software).
38 * There is currently no way of knowing whether a key is handled in SW
39 * or HW except by looking into debugfs.
11a843b7 40 *
b5c34f66
JB
41 * All key management is internally protected by a mutex. Within all
42 * other parts of mac80211, key references are, just as STA structure
43 * references, protected by RCU. Note, however, that some things are
44 * unprotected, namely the key->sta dereferences within the hardware
45 * acceleration functions. This means that sta_info_destroy() must
46 * remove the key which waits for an RCU grace period.
11a843b7
JB
47 */
48
49static const u8 bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
11a843b7 50
ad0e2b5a 51static void assert_key_lock(struct ieee80211_local *local)
3b96766f 52{
46a5ebaf 53 lockdep_assert_held(&local->key_mtx);
3b96766f
JB
54}
55
dc822b5d 56static struct ieee80211_sta *get_sta_for_key(struct ieee80211_key *key)
11a843b7 57{
11a843b7 58 if (key->sta)
dc822b5d 59 return &key->sta->sta;
11a843b7 60
dc822b5d 61 return NULL;
11a843b7
JB
62}
63
3ffc2a90 64static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
11a843b7 65{
dc822b5d
JB
66 struct ieee80211_sub_if_data *sdata;
67 struct ieee80211_sta *sta;
11a843b7
JB
68 int ret;
69
3b96766f
JB
70 might_sleep();
71
e31b8213 72 if (!key->local->ops->set_key)
3ffc2a90 73 goto out_unsupported;
11a843b7 74
ad0e2b5a
JB
75 assert_key_lock(key->local);
76
dc822b5d
JB
77 sta = get_sta_for_key(key);
78
e31b8213
JB
79 /*
80 * If this is a per-STA GTK, check if it
81 * is supported; if not, return.
82 */
83 if (sta && !(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE) &&
84 !(key->local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK))
85 goto out_unsupported;
86
dc822b5d 87 sdata = key->sdata;
18890d4b
HS
88 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
89 /*
90 * The driver doesn't know anything about VLAN interfaces.
91 * Hence, don't send GTKs for VLAN interfaces to the driver.
92 */
93 if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE))
94 goto out_unsupported;
dc822b5d
JB
95 sdata = container_of(sdata->bss,
96 struct ieee80211_sub_if_data,
97 u.ap);
18890d4b 98 }
11a843b7 99
12375ef9 100 ret = drv_set_key(key->local, SET_KEY, sdata, sta, &key->conf);
11a843b7 101
e31b8213 102 if (!ret) {
11a843b7 103 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
aac6af55 104
eaef6a93
MSS
105 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
106 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)))
aac6af55
YAP
107 key->local->crypto_tx_tailroom_needed_cnt--;
108
e31b8213
JB
109 return 0;
110 }
11a843b7 111
e31b8213 112 if (ret != -ENOSPC && ret != -EOPNOTSUPP)
0fb9a9ec
JP
113 wiphy_err(key->local->hw.wiphy,
114 "failed to set key (%d, %pM) to hardware (%d)\n",
115 key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);
3ffc2a90 116
e31b8213
JB
117 out_unsupported:
118 switch (key->conf.cipher) {
119 case WLAN_CIPHER_SUITE_WEP40:
120 case WLAN_CIPHER_SUITE_WEP104:
121 case WLAN_CIPHER_SUITE_TKIP:
122 case WLAN_CIPHER_SUITE_CCMP:
123 case WLAN_CIPHER_SUITE_AES_CMAC:
124 /* all of these we can do in software */
125 return 0;
126 default:
127 return -EINVAL;
3ffc2a90 128 }
11a843b7
JB
129}
130
131static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
132{
dc822b5d
JB
133 struct ieee80211_sub_if_data *sdata;
134 struct ieee80211_sta *sta;
11a843b7
JB
135 int ret;
136
3b96766f
JB
137 might_sleep();
138
db4d1169 139 if (!key || !key->local->ops->set_key)
11a843b7
JB
140 return;
141
ad0e2b5a
JB
142 assert_key_lock(key->local);
143
144 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
11a843b7
JB
145 return;
146
dc822b5d
JB
147 sta = get_sta_for_key(key);
148 sdata = key->sdata;
149
150 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
151 sdata = container_of(sdata->bss,
152 struct ieee80211_sub_if_data,
153 u.ap);
11a843b7 154
12375ef9 155 ret = drv_set_key(key->local, DISABLE_KEY, sdata,
24487981 156 sta, &key->conf);
11a843b7
JB
157
158 if (ret)
0fb9a9ec
JP
159 wiphy_err(key->local->hw.wiphy,
160 "failed to remove key (%d, %pM) from hardware (%d)\n",
161 key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);
11a843b7 162
3b96766f 163 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
aac6af55 164
eaef6a93
MSS
165 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
166 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)))
aac6af55 167 key->local->crypto_tx_tailroom_needed_cnt++;
3b96766f
JB
168}
169
e31b8213
JB
170void ieee80211_key_removed(struct ieee80211_key_conf *key_conf)
171{
172 struct ieee80211_key *key;
173
174 key = container_of(key_conf, struct ieee80211_key, conf);
175
176 might_sleep();
177 assert_key_lock(key->local);
178
179 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
180
181 /*
182 * Flush TX path to avoid attempts to use this key
183 * after this function returns. Until then, drivers
184 * must be prepared to handle the key.
185 */
186 synchronize_rcu();
187}
188EXPORT_SYMBOL_GPL(ieee80211_key_removed);
189
3b96766f 190static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata,
f7e0104c 191 int idx, bool uni, bool multi)
3b96766f
JB
192{
193 struct ieee80211_key *key = NULL;
194
ad0e2b5a
JB
195 assert_key_lock(sdata->local);
196
3b96766f
JB
197 if (idx >= 0 && idx < NUM_DEFAULT_KEYS)
198 key = sdata->keys[idx];
199
f7e0104c
JB
200 if (uni)
201 rcu_assign_pointer(sdata->default_unicast_key, key);
202 if (multi)
203 rcu_assign_pointer(sdata->default_multicast_key, key);
3b96766f 204
f7e0104c 205 ieee80211_debugfs_key_update_default(sdata);
3b96766f
JB
206}
207
f7e0104c
JB
208void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx,
209 bool uni, bool multi)
3b96766f 210{
ad0e2b5a 211 mutex_lock(&sdata->local->key_mtx);
f7e0104c 212 __ieee80211_set_default_key(sdata, idx, uni, multi);
ad0e2b5a 213 mutex_unlock(&sdata->local->key_mtx);
3b96766f
JB
214}
215
3cfcf6ac
JM
216static void
217__ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata, int idx)
218{
219 struct ieee80211_key *key = NULL;
220
ad0e2b5a
JB
221 assert_key_lock(sdata->local);
222
3cfcf6ac
JM
223 if (idx >= NUM_DEFAULT_KEYS &&
224 idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS)
225 key = sdata->keys[idx];
226
227 rcu_assign_pointer(sdata->default_mgmt_key, key);
228
f7e0104c 229 ieee80211_debugfs_key_update_default(sdata);
3cfcf6ac
JM
230}
231
232void ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata,
233 int idx)
234{
ad0e2b5a 235 mutex_lock(&sdata->local->key_mtx);
3cfcf6ac 236 __ieee80211_set_default_mgmt_key(sdata, idx);
ad0e2b5a 237 mutex_unlock(&sdata->local->key_mtx);
3cfcf6ac
JM
238}
239
3b96766f
JB
240
241static void __ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
242 struct sta_info *sta,
e31b8213 243 bool pairwise,
3b96766f
JB
244 struct ieee80211_key *old,
245 struct ieee80211_key *new)
246{
f7e0104c
JB
247 int idx;
248 bool defunikey, defmultikey, defmgmtkey;
3b96766f
JB
249
250 if (new)
251 list_add(&new->list, &sdata->key_list);
252
e31b8213
JB
253 if (sta && pairwise) {
254 rcu_assign_pointer(sta->ptk, new);
255 } else if (sta) {
256 if (old)
257 idx = old->conf.keyidx;
258 else
259 idx = new->conf.keyidx;
260 rcu_assign_pointer(sta->gtk[idx], new);
3b96766f
JB
261 } else {
262 WARN_ON(new && old && new->conf.keyidx != old->conf.keyidx);
263
264 if (old)
265 idx = old->conf.keyidx;
266 else
267 idx = new->conf.keyidx;
268
f7e0104c
JB
269 defunikey = old && sdata->default_unicast_key == old;
270 defmultikey = old && sdata->default_multicast_key == old;
3cfcf6ac 271 defmgmtkey = old && sdata->default_mgmt_key == old;
3b96766f 272
f7e0104c
JB
273 if (defunikey && !new)
274 __ieee80211_set_default_key(sdata, -1, true, false);
275 if (defmultikey && !new)
276 __ieee80211_set_default_key(sdata, -1, false, true);
3cfcf6ac
JM
277 if (defmgmtkey && !new)
278 __ieee80211_set_default_mgmt_key(sdata, -1);
3b96766f
JB
279
280 rcu_assign_pointer(sdata->keys[idx], new);
f7e0104c
JB
281 if (defunikey && new)
282 __ieee80211_set_default_key(sdata, new->conf.keyidx,
283 true, false);
284 if (defmultikey && new)
285 __ieee80211_set_default_key(sdata, new->conf.keyidx,
286 false, true);
3cfcf6ac
JM
287 if (defmgmtkey && new)
288 __ieee80211_set_default_mgmt_key(sdata,
289 new->conf.keyidx);
3b96766f
JB
290 }
291
b5c34f66
JB
292 if (old)
293 list_del(&old->list);
11a843b7
JB
294}
295
97359d12 296struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
faa8fdc8
JM
297 const u8 *key_data,
298 size_t seq_len, const u8 *seq)
1f5a7e47
JB
299{
300 struct ieee80211_key *key;
1ac62ba7 301 int i, j, err;
1f5a7e47 302
3cfcf6ac 303 BUG_ON(idx < 0 || idx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS);
11a843b7
JB
304
305 key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL);
1f5a7e47 306 if (!key)
1ac62ba7 307 return ERR_PTR(-ENOMEM);
11a843b7
JB
308
309 /*
310 * Default to software encryption; we'll later upload the
311 * key to the hardware if possible.
312 */
11a843b7
JB
313 key->conf.flags = 0;
314 key->flags = 0;
315
97359d12 316 key->conf.cipher = cipher;
11a843b7
JB
317 key->conf.keyidx = idx;
318 key->conf.keylen = key_len;
97359d12
JB
319 switch (cipher) {
320 case WLAN_CIPHER_SUITE_WEP40:
321 case WLAN_CIPHER_SUITE_WEP104:
76708dee
FF
322 key->conf.iv_len = WEP_IV_LEN;
323 key->conf.icv_len = WEP_ICV_LEN;
324 break;
97359d12 325 case WLAN_CIPHER_SUITE_TKIP:
76708dee
FF
326 key->conf.iv_len = TKIP_IV_LEN;
327 key->conf.icv_len = TKIP_ICV_LEN;
9f26a952 328 if (seq) {
faa8fdc8
JM
329 for (i = 0; i < NUM_RX_DATA_QUEUES; i++) {
330 key->u.tkip.rx[i].iv32 =
331 get_unaligned_le32(&seq[2]);
332 key->u.tkip.rx[i].iv16 =
333 get_unaligned_le16(seq);
334 }
335 }
76708dee 336 break;
97359d12 337 case WLAN_CIPHER_SUITE_CCMP:
76708dee
FF
338 key->conf.iv_len = CCMP_HDR_LEN;
339 key->conf.icv_len = CCMP_MIC_LEN;
9f26a952 340 if (seq) {
9190252c 341 for (i = 0; i < NUM_RX_DATA_QUEUES + 1; i++)
faa8fdc8
JM
342 for (j = 0; j < CCMP_PN_LEN; j++)
343 key->u.ccmp.rx_pn[i][j] =
344 seq[CCMP_PN_LEN - j - 1];
345 }
11a843b7
JB
346 /*
347 * Initialize AES key state here as an optimization so that
348 * it does not need to be initialized for every packet.
349 */
350 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(key_data);
1ac62ba7
BH
351 if (IS_ERR(key->u.ccmp.tfm)) {
352 err = PTR_ERR(key->u.ccmp.tfm);
3b96766f 353 kfree(key);
1f951a7f 354 return ERR_PTR(err);
11a843b7 355 }
60ae0f20
JB
356 break;
357 case WLAN_CIPHER_SUITE_AES_CMAC:
358 key->conf.iv_len = 0;
359 key->conf.icv_len = sizeof(struct ieee80211_mmie);
360 if (seq)
361 for (j = 0; j < 6; j++)
362 key->u.aes_cmac.rx_pn[j] = seq[6 - j - 1];
3cfcf6ac
JM
363 /*
364 * Initialize AES key state here as an optimization so that
365 * it does not need to be initialized for every packet.
366 */
367 key->u.aes_cmac.tfm =
368 ieee80211_aes_cmac_key_setup(key_data);
1ac62ba7
BH
369 if (IS_ERR(key->u.aes_cmac.tfm)) {
370 err = PTR_ERR(key->u.aes_cmac.tfm);
3cfcf6ac 371 kfree(key);
1f951a7f 372 return ERR_PTR(err);
3cfcf6ac 373 }
60ae0f20 374 break;
3cfcf6ac 375 }
60ae0f20
JB
376 memcpy(key->conf.key, key_data, key_len);
377 INIT_LIST_HEAD(&key->list);
3cfcf6ac 378
db4d1169
JB
379 return key;
380}
11a843b7 381
ad0e2b5a
JB
382static void __ieee80211_key_destroy(struct ieee80211_key *key)
383{
384 if (!key)
385 return;
386
d2460f4b
JB
387 /*
388 * Synchronize so the TX path can no longer be using
389 * this key before we free/remove it.
390 */
391 synchronize_rcu();
392
32162a4d
JM
393 if (key->local)
394 ieee80211_key_disable_hw_accel(key);
ad0e2b5a 395
97359d12 396 if (key->conf.cipher == WLAN_CIPHER_SUITE_CCMP)
ad0e2b5a 397 ieee80211_aes_key_free(key->u.ccmp.tfm);
97359d12 398 if (key->conf.cipher == WLAN_CIPHER_SUITE_AES_CMAC)
ad0e2b5a 399 ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm);
aac6af55 400 if (key->local) {
32162a4d 401 ieee80211_debugfs_key_remove(key);
aac6af55
YAP
402 key->local->crypto_tx_tailroom_needed_cnt--;
403 }
ad0e2b5a
JB
404
405 kfree(key);
406}
407
3ffc2a90
JB
408int ieee80211_key_link(struct ieee80211_key *key,
409 struct ieee80211_sub_if_data *sdata,
410 struct sta_info *sta)
db4d1169
JB
411{
412 struct ieee80211_key *old_key;
3ffc2a90 413 int idx, ret;
67aa030c 414 bool pairwise;
db4d1169 415
db4d1169
JB
416 BUG_ON(!sdata);
417 BUG_ON(!key);
418
67aa030c 419 pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE;
db4d1169
JB
420 idx = key->conf.keyidx;
421 key->local = sdata->local;
422 key->sdata = sdata;
423 key->sta = sta;
424
11a843b7 425 if (sta) {
11a843b7
JB
426 /*
427 * some hardware cannot handle TKIP with QoS, so
428 * we indicate whether QoS could be in use.
429 */
07346f81 430 if (test_sta_flags(sta, WLAN_STA_WME))
11a843b7
JB
431 key->conf.flags |= IEEE80211_KEY_FLAG_WMM_STA;
432 } else {
05c914fe 433 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
11a843b7
JB
434 struct sta_info *ap;
435
3b96766f 436 /*
b5c34f66
JB
437 * We're getting a sta pointer in, so must be under
438 * appropriate locking for sta_info_get().
3b96766f 439 */
d0709a65 440
11a843b7 441 /* same here, the AP could be using QoS */
abe60632 442 ap = sta_info_get(key->sdata, key->sdata->u.mgd.bssid);
11a843b7 443 if (ap) {
07346f81 444 if (test_sta_flags(ap, WLAN_STA_WME))
11a843b7
JB
445 key->conf.flags |=
446 IEEE80211_KEY_FLAG_WMM_STA;
11a843b7
JB
447 }
448 }
11a843b7
JB
449 }
450
ad0e2b5a 451 mutex_lock(&sdata->local->key_mtx);
3b96766f 452
e31b8213
JB
453 if (sta && pairwise)
454 old_key = sta->ptk;
455 else if (sta)
456 old_key = sta->gtk[idx];
d4e46a3d 457 else
db4d1169
JB
458 old_key = sdata->keys[idx];
459
e31b8213 460 __ieee80211_key_replace(sdata, sta, pairwise, old_key, key);
ad0e2b5a 461 __ieee80211_key_destroy(old_key);
d4e46a3d 462
ad0e2b5a 463 ieee80211_debugfs_key_add(key);
db4d1169 464
aac6af55
YAP
465 key->local->crypto_tx_tailroom_needed_cnt++;
466
3ffc2a90 467 ret = ieee80211_key_enable_hw_accel(key);
523d2f69 468
ad0e2b5a 469 mutex_unlock(&sdata->local->key_mtx);
3ffc2a90
JB
470
471 return ret;
1f5a7e47
JB
472}
473
3a245766 474static void __ieee80211_key_free(struct ieee80211_key *key)
1f5a7e47 475{
3b96766f
JB
476 /*
477 * Replace key with nothingness if it was ever used.
478 */
3a245766 479 if (key->sdata)
3b96766f 480 __ieee80211_key_replace(key->sdata, key->sta,
e31b8213
JB
481 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE,
482 key, NULL);
ad0e2b5a 483 __ieee80211_key_destroy(key);
3b96766f 484}
d4e46a3d 485
32162a4d
JM
486void ieee80211_key_free(struct ieee80211_local *local,
487 struct ieee80211_key *key)
3b96766f 488{
3a245766 489 if (!key)
3b96766f
JB
490 return;
491
ad0e2b5a 492 mutex_lock(&local->key_mtx);
3a245766 493 __ieee80211_key_free(key);
ad0e2b5a 494 mutex_unlock(&local->key_mtx);
3a245766
JB
495}
496
ad0e2b5a 497void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata)
3a245766
JB
498{
499 struct ieee80211_key *key;
11a843b7 500
3a245766 501 ASSERT_RTNL();
11a843b7 502
9607e6b6 503 if (WARN_ON(!ieee80211_sdata_running(sdata)))
3a245766 504 return;
11a843b7 505
ad0e2b5a 506 mutex_lock(&sdata->local->key_mtx);
11a843b7 507
aac6af55
YAP
508 sdata->local->crypto_tx_tailroom_needed_cnt = 0;
509
510 list_for_each_entry(key, &sdata->key_list, list) {
511 sdata->local->crypto_tx_tailroom_needed_cnt++;
ad0e2b5a 512 ieee80211_key_enable_hw_accel(key);
aac6af55 513 }
3b96766f 514
ad0e2b5a 515 mutex_unlock(&sdata->local->key_mtx);
11a843b7
JB
516}
517
ad0e2b5a 518void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata)
11a843b7
JB
519{
520 struct ieee80211_key *key;
521
ad0e2b5a 522 ASSERT_RTNL();
db4d1169 523
ad0e2b5a 524 mutex_lock(&sdata->local->key_mtx);
11a843b7 525
ad0e2b5a
JB
526 list_for_each_entry(key, &sdata->key_list, list)
527 ieee80211_key_disable_hw_accel(key);
11a843b7 528
ad0e2b5a 529 mutex_unlock(&sdata->local->key_mtx);
3b96766f 530}
11a843b7 531
3b96766f
JB
532void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata)
533{
534 struct ieee80211_key *key, *tmp;
db4d1169 535
ad0e2b5a 536 mutex_lock(&sdata->local->key_mtx);
3b96766f 537
3cfcf6ac 538 ieee80211_debugfs_key_remove_mgmt_default(sdata);
3b96766f
JB
539
540 list_for_each_entry_safe(key, tmp, &sdata->key_list, list)
3a245766 541 __ieee80211_key_free(key);
3b96766f 542
f7e0104c
JB
543 ieee80211_debugfs_key_update_default(sdata);
544
ad0e2b5a 545 mutex_unlock(&sdata->local->key_mtx);
11a843b7 546}
This page took 0.34633 seconds and 5 git commands to generate.